https://brlcad.org/w/api.php?action=feedcontributions&user=Phoenix&feedformat=atomBRL-CAD - User contributions [en]2020-08-09T09:20:33ZUser contributionsMediaWiki 1.32.2https://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6159User:Phoenix/GSoc2013/Reports2013-09-20T10:53:29Z<p>Phoenix: /* Final summary */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
== Week 14 ==<br />
* Sept 16<br />
** Scheduled pencils down date...<br />
** Begin to do some code clean up and improve documentations<br />
*** Use rt_db_internal instead of ON_Brep for the interface between libged and librt.<br />
* Sept 17<br />
** Added an "--no-evaluation" option, using the old routine of converting comb without NURBS evaluations (CSG tree + brep)<br />
** Scrub the code.<br />
* Sept 18<br />
** Scrub the code - src/libbrep/intersect.cpp<br />
*** Reused sub_curve() and sub_surface().<br />
*** Added and corrected some comments.<br />
* Sept 19<br />
** Rewrite the code of merging intervals in CCI and CSI<br />
*** Use only one pending interval.<br />
** Corrected some comments.<br />
* Sept 20<br />
** Added more comment to the code, to make it more understandable.<br />
<br />
== Final summary ==<br />
* During GSoC '13, I implemented 6 independent intersection routines (point/point, point/curve, point/surface, curve/curve, curve/surface and surface/surface), tested and verified them, and they proved to be robust with the input I gave (even the extreme case). The most challenging task is the overlap cases in SSI (the result is 2D rather than 1D), which takes several weeks and hundreds lines of code.<br />
* After mid-term evaluation, I started to focus on NURBS boolean evaluations with the well-performed intersection routines. The main steps include splitting a trimmed face, inside/outside tests and forming the final b-rep structure. I'm pleased that I stayed on schedule during all these time, and finally finished a working NURBS evaluation routine and COMB conversion. Connectivity graphs take quite a lot of time to implement, and still not completed in some way (e.g. the information lost after the evaluation, because the edges are not shared), but it doesn't effect the performance a lot so finally we just disable this option. If it turns out to be useful later, we can enable it again, and do some modifications if needed.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6158User:Phoenix/GSoc2013/Reports2013-09-20T10:53:18Z<p>Phoenix: /* Final summary */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
== Week 14 ==<br />
* Sept 16<br />
** Scheduled pencils down date...<br />
** Begin to do some code clean up and improve documentations<br />
*** Use rt_db_internal instead of ON_Brep for the interface between libged and librt.<br />
* Sept 17<br />
** Added an "--no-evaluation" option, using the old routine of converting comb without NURBS evaluations (CSG tree + brep)<br />
** Scrub the code.<br />
* Sept 18<br />
** Scrub the code - src/libbrep/intersect.cpp<br />
*** Reused sub_curve() and sub_surface().<br />
*** Added and corrected some comments.<br />
* Sept 19<br />
** Rewrite the code of merging intervals in CCI and CSI<br />
*** Use only one pending interval.<br />
** Corrected some comments.<br />
* Sept 20<br />
** Added more comment to the code, to make it more understandable.<br />
<br />
== Final summary ==<br />
** During GSoC '13, I implemented 6 independent intersection routines (point/point, point/curve, point/surface, curve/curve, curve/surface and surface/surface), tested and verified them, and they proved to be robust with the input I gave (even the extreme case). The most challenging task is the overlap cases in SSI (the result is 2D rather than 1D), which takes several weeks and hundreds lines of code.<br />
** After mid-term evaluation, I started to focus on NURBS boolean evaluations with the well-performed intersection routines. The main steps include splitting a trimmed face, inside/outside tests and forming the final b-rep structure. I'm pleased that I stayed on schedule during all these time, and finally finished a working NURBS evaluation routine and COMB conversion. Connectivity graphs take quite a lot of time to implement, and still not completed in some way (e.g. the information lost after the evaluation, because the edges are not shared), but it doesn't effect the performance a lot so finally we just disable this option. If it turns out to be useful later, we can enable it again, and do some modifications if needed.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6157User:Phoenix/GSoc2013/Reports2013-09-20T10:40:12Z<p>Phoenix: /* Week 14 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
== Week 14 ==<br />
* Sept 16<br />
** Scheduled pencils down date...<br />
** Begin to do some code clean up and improve documentations<br />
*** Use rt_db_internal instead of ON_Brep for the interface between libged and librt.<br />
* Sept 17<br />
** Added an "--no-evaluation" option, using the old routine of converting comb without NURBS evaluations (CSG tree + brep)<br />
** Scrub the code.<br />
* Sept 18<br />
** Scrub the code - src/libbrep/intersect.cpp<br />
*** Reused sub_curve() and sub_surface().<br />
*** Added and corrected some comments.<br />
* Sept 19<br />
** Rewrite the code of merging intervals in CCI and CSI<br />
*** Use only one pending interval.<br />
** Corrected some comments.<br />
* Sept 20<br />
** Added more comment to the code, to make it more understandable.<br />
<br />
== Final summary ==<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6150User:Phoenix/GSoc2013/Reports2013-09-19T07:42:31Z<p>Phoenix: /* Week 14 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
== Week 14 ==<br />
* Sept 16<br />
** Scheduled pencils down date...<br />
** Begin to do some code clean up and improve documentations<br />
*** Use rt_db_internal instead of ON_Brep for the interface between libged and librt.<br />
* Sept 17<br />
** Added an "--no-evaluation" option, using the old routine of converting comb without NURBS evaluations (CSG tree + brep)<br />
** Scrub the code.<br />
* Sept 18<br />
** Scrub the code - src/libbrep/intersect.cpp<br />
*** Reused sub_curve() and sub_surface().<br />
*** Added and corrected some comments.<br />
* Sept 19<br />
** Rewrite the code of merging intervals in CCI and CSI<br />
*** Use only one pending interval.<br />
** Corrected some comments.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6147User:Phoenix/GSoc2013/Reports2013-09-18T09:20:43Z<p>Phoenix: /* Week 14 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
== Week 14 ==<br />
* Sept 16<br />
** Scheduled pencils down date...<br />
** Begin to do some code clean up and improve documentations<br />
*** Use rt_db_internal instead of ON_Brep for the interface between libged and librt.<br />
* Sept 17<br />
** Added an "--no-evaluation" option, using the old routine of converting comb without NURBS evaluations (CSG tree + brep)<br />
** Scrub the code.<br />
* Sept 18<br />
** Scrub the code - src/libbrep/intersect.cpp<br />
*** Reused sub_curve() and sub_surface().<br />
*** Added and corrected some comments.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6146User:Phoenix/GSoc2013/Reports2013-09-18T02:54:02Z<p>Phoenix: /* Week 14 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
== Week 14 ==<br />
* Sept 16<br />
** Scheduled pencils down date...<br />
** Begin to do some code clean up and improve documentations<br />
*** Use rt_db_internal instead of ON_Brep for the interface between libged and librt.<br />
* Sept 17<br />
** Added an "--no-evaluation" option, using the old routine of converting comb without NURBS evaluations (CSG tree + brep)<br />
** Scrub the code.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6141User:Phoenix/GSoc2013/Reports2013-09-16T12:53:12Z<p>Phoenix: /* Week 14 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
== Week 14 ==<br />
* Sept 16<br />
** Scheduled pencils down date...<br />
** Begin to do some code clean up and improve documentations<br />
*** Use rt_db_internal instead of ON_Brep for the interface between libged and librt.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6140User:Phoenix/GSoc2013/Reports2013-09-16T12:52:59Z<p>Phoenix: /* Week 13 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
== Week 14 ==<br />
** Scheduled pencils down date...<br />
** Begin to do some code clean up and improve documentations<br />
*** Use rt_db_internal instead of ON_Brep for the interface between libged and librt.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6130User:Phoenix/GSoc2013/Reports2013-09-13T13:37:31Z<p>Phoenix: /* Week 13 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
* Sept 13<br />
** Still fixing memory leaks.<br />
*** Face splitting.<br />
*** Tree conversion.<br />
*** Passed valgrind tests well after lots of efforts.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6126User:Phoenix/GSoc2013/Reports2013-09-12T13:45:15Z<p>Phoenix: /* Week 13 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
* Sept 12<br />
** Continued using valgrind to fix the memory leaks.<br />
*** boolean.cpp<br />
*** SSI (intersect.cpp)<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6120User:Phoenix/GSoc2013/Reports2013-09-11T14:34:55Z<p>Phoenix: /* Week 13 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
* Sept 11<br />
** Some minor changes in libbrep/boolean.cpp<br />
** Installed and studied valgrind<br />
*** Fixed memory leaks in test_point_intersect and test_curve_intersect.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6115User:Phoenix/GSoc2013/Reports2013-09-10T09:55:30Z<p>Phoenix: /* Week 13 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
* Sept 10<br />
** Surface equality checking<br />
*** Also checked their degree (order) and knots<br />
** "Robustness Issues"<br />
*** Improve inside/outside tests for the cases with overlap surfaces.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6109User:Phoenix/GSoc2013/Reports2013-09-09T08:55:44Z<p>Phoenix: /* Week 12 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
== Week 13 ==<br />
* Sept 9<br />
** The school starts...<br />
** Improved the boolean evaluations<br />
*** Use the same surface if they are split from the same face.<br />
*** Fix wrong vertex for the singular trims.<br />
*** Detect whether the surfaces are the same - don't need SSI if they are the same.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6098User:Phoenix/GSoc2013/Reports2013-09-06T08:06:41Z<p>Phoenix: /* Test Results */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersect.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6097User:Phoenix/GSoc2013/Reports2013-09-06T08:06:06Z<p>Phoenix: /* Test Results */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result of union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
** Two arb8 (first: union, second: intersection, third: diff)<br />
** [[Image:Arb union.png]] [[Image:Arb intersection.png]] [[Image:Arb diff.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=File:Arb_diff.png&diff=6096File:Arb diff.png2013-09-06T08:05:01Z<p>Phoenix: </p>
<hr />
<div></div>Phoenixhttps://brlcad.org/w/index.php?title=File:Arb_intersect.png&diff=6095File:Arb intersect.png2013-09-06T08:04:46Z<p>Phoenix: </p>
<hr />
<div></div>Phoenixhttps://brlcad.org/w/index.php?title=File:Arb_union.png&diff=6094File:Arb union.png2013-09-06T08:04:30Z<p>Phoenix: </p>
<hr />
<div></div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6093User:Phoenix/GSoc2013/Reports2013-09-06T08:03:30Z<p>Phoenix: /* Week 12 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_face(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6092User:Phoenix/GSoc2013/Reports2013-09-06T08:03:12Z<p>Phoenix: /* Week 12 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
* Sept 6<br />
** Tests and fixed some bugs in libbrep/boolean.cpp<br />
*** get_subcurve_inside_surface(): It should be the intersection of the two merged intervals, not union. And there might be no intersections (e.g. for an inner loop)<br />
*** A slight bug: m_a => m_b (wrong param used)<br />
*** Uploaded images to wiki.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6089User:Phoenix/GSoc2013/Reports2013-09-05T11:15:37Z<p>Phoenix: /* Week 12 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
* Sept 5<br />
** Fixed wrong face direction of arbn => brep conversion<br />
*** The problem existed in rt_nmg_brep().<br />
** Fixed a bug in trimmed face splitting<br />
*** Pointers may be invalid if the ON_SimpleArray's capacity is enlarged.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6088User:Phoenix/GSoc2013/Reports2013-09-04T09:48:33Z<p>Phoenix: /* Week 12 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
* Sept 4<br />
** Renamed some variables.<br />
*** db => dbip<br />
*** brep_conversion => single_conversion<br />
** Performed Xform on the leaves.<br />
** Checked 3D distance (not included in ON_Brep::IsValid()) when looking for seam trims.<br />
** Generated the connectivity graph for the new solid (after evaluation)<br />
** Discussions about db_i passing in rt_comb_brep().<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6084User:Phoenix/GSoc2013/Reports2013-09-03T09:16:16Z<p>Phoenix: /* Week 12 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
* Sept 3<br />
** Correctly reuse surface trees and curve trees.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6077User:Phoenix/GSoc2013/Reports2013-09-02T11:03:46Z<p>Phoenix: /* Week 11 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
== Week 12 ==<br />
* Sept 2<br />
** Solve some invalid ON_Brep representations<br />
*** Avoid duplicated vertexes.<br />
*** ISO type should be checked before we decide whether to share seam curves.<br />
** Some code clean up.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6070User:Phoenix/GSoc2013/Reports2013-08-30T17:11:04Z<p>Phoenix: /* Week 11 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
* Aug 30<br />
** Began to implement comb -> brep conversion, as the NURBS evaluations are ready now.<br />
*** Currently we need to pass the db_i* param all the way, because the comb tree only stores the names in the leaves, and we need the db to find the solid. Is there any more elegant way to deal with this?<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6067User:Phoenix/GSoc2013/Reports2013-08-29T09:38:05Z<p>Phoenix: /* Test Results */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (first: result union; second: result of intersection; third: result of difference)<br />
** [[Image:union_sph.png]] [[Image:sph_sph_inter.png]] [[Image:diff_sph.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=File:Diff_sph.png&diff=6066File:Diff sph.png2013-08-29T09:34:42Z<p>Phoenix: </p>
<hr />
<div></div>Phoenixhttps://brlcad.org/w/index.php?title=File:Union_sph.png&diff=6065File:Union sph.png2013-08-29T09:34:25Z<p>Phoenix: </p>
<hr />
<div></div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6064User:Phoenix/GSoc2013/Reports2013-08-29T09:28:10Z<p>Phoenix: /* Week 11 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
** Tested boolean evaluations and uploaded result images.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (left: original structures; right: result of intersection)<br />
** [[Image:sph_sph.png]] [[Image:sph_sph_inter.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6063User:Phoenix/GSoc2013/Reports2013-08-29T09:26:09Z<p>Phoenix: /* Week 11 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
* Aug 29<br />
** Some code clean up.<br />
** Fixed wrong face direction.<br />
** Added another boolean operation - XOR.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (left: original structures; right: result of intersection)<br />
** [[Image:sph_sph.png]] [[Image:sph_sph_inter.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6056User:Phoenix/GSoc2013/Reports2013-08-28T09:52:01Z<p>Phoenix: /* Week 11 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
* Aug 28<br />
** Tried to pass ON_Brep::IsValid().<br />
*** Added seaming trims, using the methods similar to the checking code in IsValid().<br />
*** Dealt with singular trims and closed trims.<br />
*** Solved trim & vertex mismatch.<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (left: original structures; right: result of intersection)<br />
** [[Image:sph_sph.png]] [[Image:sph_sph_inter.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6052User:Phoenix/GSoc2013/Reports2013-08-27T13:39:15Z<p>Phoenix: /* Test Results */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:ehy_tor.png]] [[Image:ehy_tor_inter.png]]<br />
** Two spheres (left: original structures; right: result of intersection)<br />
** [[Image:sph_sph.png]] [[Image:sph_sph_inter.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6051User:Phoenix/GSoc2013/Reports2013-08-27T13:38:03Z<p>Phoenix: /* Test Results */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may lack accuracy (we may not have points on the boundaries)<br />
* July 17<br />
** Some slight modifications to SSI (Commit 56091)<br />
** Solved the under-determined system with Newton iterations using pseudo-inverse. (ON_Matrix::Invert()) can do this)<br />
** Began working on overlaps:<br />
*** Bezier patches satisfy the theorem 3 mentioned above. Since the Bezier patches for a NURBS surface are always bounded at the knots, we actually don't need to generate the Bezier patches explicitly, and we can get the boundaries of them using IsoCurve() on knots.<br />
*** Get the 3D overlap boundary segments. (2D is working in process because CSI doesn't report a 2D curve on the surface)<br />
*** Some tests and bug fixing.<br />
* July 18<br />
** Generate a 2D curve on the surface for csx_overlap, so that we can have two 2D curves for ssx_overlap. (Debugged for a long time, because ~ON_CurveArray() will delete the curves)<br />
** Linked the curves together to form a loop. (Continued to discuss about solutions of overlap cases with Cliff)<br />
** Changed the direction of curves if necessary to satisfy the requirements of ON_SSX_EVENT. (For ssx_transverse events, the 3d curve direction agrees with SurfaceNormalB x SurfaceNormalA. For ssx_tangent events, the orientation is random. For ssx_overlap events, the overlap region should be to the LEFT of that *m_curveA*.)<br />
* July 19<br />
** Read a paper provided by Cliff regarding sub-surface intersections using quasi-interpolating control net. But unfortunately it doesn't provide much help. Continued to discuss about solutions to surface-surface overlaps on the mailing list.<br />
** Recognized that there might be inner loops, so the original code only make sure that the left on the curve is the closed region, but not the overlap region if it's an inner loop. Used point-surface intersections to determined which side of the curve is actually the intersection.<br />
== Week 6 ==<br />
* July 22<br />
** Eliminate the bounding boxes completely inside the overlap region, and intersection points inside the overlaps.<br />
** Determine inner loops and outer loops of the overlap region.<br />
** Pass trees to the point-surface intersections to avoid repeatedly generate the surface trees.<br />
** Test whether the overlap curve is an inner segment by testing whether the two sides of it are shared or not.<br />
* July 23<br />
** Posted my progress on the mailing list.<br />
** Coding part:<br />
*** Dealt with closed domains for the overlap curve segments.<br />
*** Fixed the return values of ON_Intersect()s when x may not be empty initially.<br />
*** Normalized the curves for ssx_overlap.<br />
*** Some code clean up and added some comment to document the new features.<br />
** Tested the overlaps and uploaded images to this log.<br />
* July 24<br />
** Handled degenerated cases (the curve is degenerated to a point) for C/C and C/S intersections.<br />
** Fixed two bugs of SSI<br />
*** A variable (knots) is deleted before where it's used.<br />
*** Set the pointer to NULL after it's deleted otherwise Split() will failed if the pointer is passed in.<br />
** Tested on the an extreme geometry provided by Cliff, and figured out what I should do next for the overlap case of SSI.<br />
* July 25<br />
** Fix a bug in linking overlap segments (the index should start from 0)<br />
** Use surface normals to help determine overlaps. The normals of the two surfaces should be parallel.<br />
** Modified the CSI sub-division routine. The sub-division should only stops when the curve is linear AND the surface is planar. Otherwise there might be problems with csx_overlap.<br />
** Continued to modify the surface-surface overlaps with the test case: extreme_ssi_test.g (added to source tree). The modification is not finished yet.<br />
* July 26<br />
** Improved SSI with the extreme test case.<br />
*** Used a struct to represent the overlap segments. Split the curves with the intersection points (with other curves), so that we can get closed regions.<br />
*** Fixed a bug that cause sub_curve() to crash.<br />
== Week 7 ==<br />
* July 28<br />
** Removed debug messages.<br />
** Uploaded test result (2D intersection curves) of extreme_ssi_test.g.<br />
** Still some work needed before we can have the final result.<br />
* July 29<br />
** Generating 2D overlapping curves in CSI used to have a wrong ordered point list. Fixed this by ignoring some inner points.<br />
** Removed the duplicated overlap curves.<br />
** There is something wrong with the screen of my laptop. So I sent it to repair. Hope I can get it back soon and continue to work.<br />
* July 30<br />
** Struggled to build up the environment using virtual machines on our school's computer since I cannot use my own laptop now.<br />
** Fixed the wrong logic of determining whether a bounding box (or a point) is inside an overlap region or not.<br />
* July 31<br />
** Discussed about r56303 on the mailing list.<br />
** Take the tolerance into consideration when deciding whether a box is inside the overlap region.<br />
** Delete the OverlapSegment when its curves are NULL.<br />
** Some code clean up<br />
*** Eliminate compiler warnings.<br />
*** Avoid using dynamic memory allocation for the events.<br />
*** Use build_curve_root() instead of duplicating that routine.<br />
*** Use sub_curve() instead of repeating that routine.<br />
* Aug 1<br />
** Testing "brep arb8.brep intersect ehy.brep 0 1 on csgbrep.g" failed. It seemed that J.invert() doesn't work. Used explicit pseudo-inverse.<br />
** Some code clean up.<br />
** Tried to implement PSI in a similar fashion of other intersections, so that further the surface tree structures can be easily reused during different intersections.<br />
* Aug 2<br />
** Reuse the surface trees and curve trees during multiple intersections to reduce repeat computation.<br />
** Tested the SSI and fixed several bugs:<br />
*** The tests on the overlap cases failed again. Tracked the changed since the last correct routine to find the problem.<br />
*** Found several slight bugs and fixed them, and the result is correct now.<br />
*** Committed the changes separately.<br />
* Aug 3<br />
** More powerful handling for the direction of overlap curves. Try another two options if the mid point is not sufficient.<br />
** Upload the final result of the extreme case.<br />
== Mid-term summary ==<br />
The week 7 is the mid-term evaluations. During the first half of GSoC, I focused on the NURBS intersections, implemented P/P, P/C, P/S, C/C, C/S intersections, and also made lots of improvements on the SSI implemented last year, e.g. Newton iterations, overlap cases. Now according to the schedule, we are going to the next half of GSoC next week, and I'll start working on evaluating NURBS booleans.<br />
<br />
A friendly remind of how to tests my results. If you want to have a quick test on P/P, P/C and P/S, you can run src/libbrep/test_point_intersect, or src/libbrep/test_curve_intersect for C/C and C/S. If you want to test SSI, you need to run librt/tests/test_ssi, but it doesn't have build-in test cases, so you need to specify a .g file, and the objects in it. Also, you can use the brep command in MGED, which can test all of these six intersections.<br />
<br />
== Week 8 ==<br />
* Aug 5<br />
** Start to work on evaluating NURBS booleans.<br />
*** Move the existing code in librt (written last summer) to libbrep, and use a separated file libbrep/boolean.c.<br />
*** Fixed a small bug in the existing code (m_curveA => m_curveB)<br />
** Help eliminate compiler warnings (and errors) in other files.<br />
* Aug 6<br />
** Make sub_curve() a global export function, and mark all other functions that should be only used within intersect.cpp with HIDDEN.<br />
** Revisited the code in libbrep/boolean.cpp, and lots of updates:<br />
*** Used ON_Curve rather than ON_NurbsCurve for better generality.<br />
*** Eliminated the polyline curve assumption.<br />
** Tests the existed boolean evaluations, and found problems that I'm going to fix. (brep arb8.brep u ehy.brep union for csgbrep.g)<br />
* Aug 7<br />
** Modified split_trimmed_face() in libbrep/boolean.cpp<br />
*** Fixed some bugs.<br />
*** Used an enum to improve readablity of m_in_out.<br />
*** Special handling for the first and last point.<br />
*** Multiple inner loops (using std::vector)<br />
*** Implemented IsPointInsideLoop() to help determine a curve is completely inside a loop or not.<br />
** Fixed a bug in CCI<br />
*** The result after the Newton iterations might be nan.<br />
* Aug 8<br />
** Modified add_elements()<br />
*** Added vertexes correctly.<br />
*** Use ON_Curve rather than ON_NurbsCurve to reduce unnecessary conversions.<br />
** Fixed a bug in splitting surfaces - if the SSI event is not curves events, we don't need to do anything.<br />
** Found some cases that SSI curves may intersect, and the surface splitting routine only assumes that they are non-intersecting chains. Struggled to find a way to deal with this.<br />
* Aug 9<br />
** Fixed two bugs in split_trimmed_surface()<br />
*** Don't call Split() when t is on the boundary of domain.<br />
*** The first point is not always on the first segment, so we might need to duplicate more than one segments.<br />
** Linked the curves if they share an end point<br />
*** They can be from intersections with different surfaces<br />
*** Or they are discontinuous in the other surface's domain, so not linked originally.<br />
== Week 9 ==<br />
* Aug 12<br />
** Continued working on splitting trimmed faces.<br />
*** Implement a function to check the validity of the outer loop before adding a trimmed face.<br />
** Some code clean up in libbrep/boolean.cpp.<br />
* Aug 13<br />
** Modified split_trimmed_face().<br />
*** Take care of the intersection tolerance, and "fix" the "gaps" if necessary.<br />
*** Fixed bugs - NormalizedParameterAt() => ParameterAt(); floating point comparisons.<br />
*** Renamed a used macro (DEBUG => DEBUG_BREP_BOOLEAN)<br />
* Aug 14<br />
** Used a better method to determine m_in_out - don't always assume that the starting point is outside, but use IsPointInsideLoop() to check around that point to determine it's going inside or outside.<br />
** Some other minor modifications - move link_curves() to ON_Boolean(), and ignore ssx_overlap curves when partitioning the face.<br />
* Aug 15<br />
** Tried improving surface partitioning<br />
*** Handled the case when an SSI curve overlaps with the outer loop.<br />
*** Implemented get_subcurve_inside_faces().<br />
*** Ignored UNSET IntersectPoints when maintaining the stack.<br />
* Aug 16<br />
** Finished surface partitioning<br />
*** Eliminated the usage of sorted_pointers[] - once the array intersect[] is enlarged (with a new capacity), the pointers stored in sorted_pointers[] is no longer valid.<br />
*** Tests, verification, and some minor changes.<br />
*** Code clean up and added comment.<br />
== Week 10 ==<br />
* Aug 19<br />
** Studied the paper about connectivity graphs.<br />
** Added basic support of connectivity graph. And built connectivity graphs for the original structure.<br />
*** Tests and fixed bugs.<br />
* Aug 20<br />
** Struggled to find a way updating the connectivity graph after surface partitioning.<br />
*** More information about the edge sharing during the splitting procedure is needed.<br />
*** Tried several ways but sucked, and finally came out an awkward implementation.<br />
* Aug 21<br />
** Continued working on connectivity graphs<br />
*** Defined a macro to make the connectivity graph an optional choice.<br />
*** Use an array of intervals to represent which part of the parent's outer loop that a TrimmedFace occupies.<br />
* Aug 22<br />
** Code clean up - rename class members with "m_" prefix, use ON_ClassArray rather than "new" and "delete" operators.<br />
** Keep the information of the usage of SSI curve, so that we can know the connection between two trimmed faces (split from two surfaces), and get the connectivity graph of the new geometry after boolean evaluation.<br />
* Aug 23<br />
** Keep the original curve segments in LinkedCurve so that we can then share an edge with a neighboring face after we get the final evaluated structure.<br />
*** But this is still not enough. Maybe it should be postponed until we get to that stage, so that we can know actually what information are needed.<br />
** Start to work on inside/outside tests<br />
*** Use curve-surface intersections to determine a point is inside a Brep or not.<br />
*** Sean suggests using rt_brep_shot(). I'll look into that routine in brep.cpp (using for NURBS ray tracing) and find what can be reused.<br />
== Week 11 ==<br />
* Aug 25<br />
** Looked into rt_brep_shot(). It needs to build the whole surface tree before we can process. I think it's not a good option for our inside/outside test. With CSI, deciding whether a point is inside a brep is quite easy.<br />
* Aug 26<br />
** Implemented IsFaceInsideBrep() to decide whether a trimmed face is inside another brep.<br />
*** Used randomly generated points.<br />
*** Used it to decide whether the trimmed faces belong to the final structure according to type of the operation.<br />
** Modified the brep command in MGED.<br />
* Aug 27<br />
** Flip the face if necessary (according to the operation and original face's bRev)<br />
** Made use of the connectivity graph to reduce inside/outside tests (if the USE_CONNECTIVITY_GRAPH flag is set).<br />
** Upload images to the wiki to show the result of NURBS boolean evaluations (intersection).<br />
<br />
= Test Results =<br />
* src/librt/tests/arb_intersect.g<br />
** Intersection point: brep A_brep intersect B_brep 0 4 (The intersection point is marked with a sphere)<br />
*** [[Image:Arb point.png]]<br />
** Intersection curve (a line segment): brep A_brep intersect B_brep 0 1 (The intersection line is marked as green and purple)<br />
*** [[Image:Arb line.png]]<br />
* csgbrep.g<br />
** brep tor.brep intersect sph.brep 0 0<br />
*** 2 intersection curves (2 circles)<br />
*** [[Image:Sph tor.png]]<br />
*** 3D intersection curves (generated by test_ssi as pipe primitives)<br />
*** [[Image:Sph tor 3d.png]]<br />
*** 2D intersection curves (generated by test_ssi as sketch primitives): as you can see, they are two line segments.<br />
*** [[Image:Sph tor 2dA.png]] [[Image:Sph tor 2dB.png]]<br />
* Intersection of two rcc's (They both have a bottom face that overlaps with each other, and the intersection curve of their side faces is a circle displayed in green.)<br />
** [[Image:Rcc circle.png]]<br />
* We translate and rotate the blue rcc, and intersect again its side face with the red one's side face, and get a 3D intersection curve. (Displayed in green)<br />
** [[Image:Rcc 3dcurve.png]]<br />
* This time, their bottom are in the same plane, but only partly overlapped. The intersection of their side faces should be two points (If you look at the image below carefully, you can see a green point in the intersection).<br />
** [[Image:Rcc point.png]]<br />
* The below intersection has been described in paper http://www.sciencedirect.com/science/article/pii/0010448596000139. At a glance, the intersections look perfect (The left are 3D intersections and the right are 2D parametric ones.) But if you zoom the view, you can see some difference (The third image)<br />
** [[Image:Rcc ortho 3d.png]] [[Image:Rcc ortho 2d.png]] [[Image:Rcc ortho zoom.png]]<br />
** ''''' This problem raised because the two intersection curves intersect with each other, but according to our fitting mechanism, one intersection point can only belong to ONE curve, and points can not be duplicated. So you can see that the two curves are actually separated when zoomed. How to solve this problem? I'm still struggling to find a solution. Hope anyone who see this log can share your ideas. :) '''''<br />
** ''''' Some work on July 15 (using seaming segments) is to solve this problem. '''''<br />
* An elliptic parabolic surface (epa side face) and a plane.<br />
** The left image is the result before we use separate max_dis_u (v, s and t). The right image is the result after we fix this. The problem raises because the domain of the two parameters differ a lot (one is [0, 6.28] and the other is [0, 2000]). For example, two points (0, 0) and (6.28, 1) should not be neighbors, of course, but in the global scale majorly determined by the large domain [0, 2000], they become neighbors and the result is totally messy.<br />
** [[Image:epa_bad.png]] [[Image:epa_good.png]]<br />
** The below are 2D parametric curves. The left is the projection on the plane surface (it's a parabola) and the right is the projection on the parabolic surface (it's some line segments).<br />
** [[Image:epa_2d_for_plane.png]] [[Image:epa_2d_for_parabola.png]]<br />
* Test ssx_overlap on planes (src/librt/tests/arb_intersect.g).<br />
** brep A_brep intersect C_brep 0 1<br />
** Part of the two surfaces overlap.<br />
** [[Image:partial_overlap.png]]<br />
** brep A_brep intersect A_brep 0 0<br />
** We intersect two surfaces that are exactly the same. Maybe this case can be optimized (Detect it's a duplicated surface and return the boundary of the whole surface directly).<br />
** [[Image:completely_overlap.png]]<br />
* The extreme test case (src/librt/tests/extreme_ssi_test.g):<br />
** The 2D intersect curves generated as sketch primitives by test_ssi: test_ssi extreme_ssi_tests.g surface_1.s surface_2.s 0 0 (the 2D curves on surface A and those on surface B is the same). (New: the right one includes two intersection curves)<br />
** [[Image:Five rec.png]] [[Image:extreme_final.png]]<br />
* NURBS boolean evaluations (intersection)<br />
** An arb8 and an ehy (left: original structures; right: result of intersection)<br />
** [[Image:arb8_ehy.png]] [[Image:arb8_ehy_inter.png]]<br />
** A sph and a torus (left: original structures; right: result of intersection)<br />
** [[Image:sph_tor.png]] [[Image:sph_tor_inter.png]]<br />
** Two spheres (left: original structures; right: result of intersection)<br />
** [[Image:sph_sph.png]] [[Image:sph_sph_inter.png]]<br />
<br />
= Original development timeline =<br />
* - June 17 (~4 weeks)<br />
** Study the papers on this topic<br />
** Discuss with other developers<br />
** Some code clean up in the current SSI routine<br />
** Write a test program to test SSI<br />
* June 17 - June 23 (1 week)<br />
** Lower dimension intersections<br />
*** P/P, P/C, P/S<br />
*** With the support of openNURBS<br />
** Tests and documentations<br />
* June 24 - July 7 (2 weeks)<br />
** Intersections regarding curves<br />
*** C/C, C/S<br />
*** Subdivision - curve trees, surface trees<br />
** Tests and documentations<br />
* July 7 - Aug. 4 (4 weeks)<br />
** TDD on SSI<br />
*** Test the SSI<br />
*** Find the problems<br />
*** Fix the bugs<br />
*** Find more bugs and fix them<br />
*** Degenerated cases<br />
** Try to get the code faster<br />
*** Fit the curve to a lower order if possible<br />
** Documentations<br />
*** Comment in code<br />
*** Write some extra document on SSI (algorithms, problems, TODOs...)<br />
** Mid-term evaluation in July 29 - Aug. 2<br />
* Aug. 5 - Aug. 18 (2 weeks)<br />
** Finish the surface partitioning<br />
*** Polygon partitioning<br />
*** Curve-curve intersection<br />
** Tests<br />
*** Trims may intersect<br />
* Aug. 19 - Aug. 25 (1 week)<br />
** Add connectivity graph support<br />
*** Generate connectivity graphs for objects<br />
*** Design proper data structures for the graph<br />
* Aug. 26 - Sept. 1 (1 week)<br />
** Inside-outside tests<br />
*** Curve-surface intersection<br />
*** BFS of the graph to determine inside/outside<br />
* Sept. 2 - Sept. 8 (1 week)<br />
** Generate valid ON_Brep objects<br />
*** Read code in IsValid() functions<br />
*** Add elements (trim, edge, etc.)<br />
*** Try to pass the validation<br />
** Extend the brep command in MGED<br />
* Sept. 9 - Sept. 15<br />
** Robustness Issues<br />
*** Deal with the degenerated cases<br />
*** All 3 steps should be modified<br />
** Tests<br />
*** Fix bugs<br />
*** Improve performance<br />
* Sept. 16 - Sept. 22 (1 week)<br />
** Pencils down<br />
*** Code clean up<br />
*** Documentation (wiki pages)<br />
* Sept. 23 - Sept. 27 (1 week)<br />
** Final evaluation<br />
** Submit code to Google</div>Phoenixhttps://brlcad.org/w/index.php?title=User:Phoenix/GSoc2013/Reports&diff=6050User:Phoenix/GSoc2013/Reports2013-08-27T13:35:00Z<p>Phoenix: /* Week 11 */</p>
<hr />
<div>= Log =<br />
== Community bonding ==<br />
* May 28<br />
** Create the log page<br />
** Things have done:<br />
*** Test program for SSI and a test geometry file<br />
*** Some improvement with SSI and API design<br />
* June 3<br />
** As I will have my final exams during the first week that coding begins, so I'd like to move some work ahead.<br />
** Begin to add P/P, P/C and P/S support. Implement ON_PX_EVENT for reporting the intersections.<br />
** TODO: Implement P/C, P/S and ON_PX_EVENT::IsValid().<br />
* June 4<br />
** Eliminate max_dis in the brep command for SSI.<br />
** Extended the brep command to handle P/P, P/C, P/S, C/C and C/S.<br />
** Modified the wiki page of the brep command.<br />
** Fix the format of ON_PX_EVENT::Dump(). (Add "\n")<br />
* June 7<br />
** Try to add PS support using get_closest_point().<br />
** Test the functionality of the PS function - it seems that there's a problem when try (0,0,5) on a sphere of radius 5 and centered at the origin (it should be an intersect, but get_closest_point() returns (0,0,-5) resulting in no intersections).<br />
* June 12<br />
** Calculate point-curve intersection using sub-division.<br />
** Do some simple testing on PCI. It works.<br />
<br />
== Week 1 ==<br />
* June 17<br />
** Coding period begins!<br />
** Put the tolerance into consideration in the IsPointIn() test in PCI.<br />
** Write a test program on sphere to test P/P, P/C and P/S.<br />
*** <s>It seems that get_closest_point() is not always robust. :( Maybe it's not a good choice for P/S.</s><br />
* June 18<br />
** Use macros to represent default tolerance and change it to 0.001 (the same as the default tolerance of curve/curve, curve/surface, surface/surface defined by openNURBS)<br />
** Consider the input u_domain and v_domain for the result of point-surface intersection.<br />
* June 19<br />
** Busy with the course projects and preparing a final exam. Didn't have much time for BRL-CAD.<br />
* June 20<br />
** Found the problem causing get_closest_point() to fail<br />
*** get_closest_point() sometimes give us the 'farthest' point.<br />
*** => getClosestPointEstimate() didn't work.<br />
*** => The surface tree are not built correctly.<br />
*** => It seems that we inappropriately prepTrims when m_removeTrimmed is false, causing get_closest_point() to fail. Someone who wrote this code needs to check whether this change is correct.<br />
** Use a smaller depth for PSI to improve performance.<br />
* June 21<br />
** Added Newton-Raphson iteration in PCI to improve accuracy (using the one from subdivision and linear approximation as a starting point)<br />
*** After test, it can work with tolerance set to ON_ZERO_TOLERANCE!<br />
== Week 2 ==<br />
* June 24<br />
** The plane was delayed for a long time. It took almost the whole day to get to Beijing. :(<br />
** Set removeTrimmed to false, otherwise the surface tree cannot be built correctly - since the last change raised a raytrace problem.<br />
* June 25<br />
** Began to implement curve-curve intersections.<br />
*** First using sub-division to find the intersecting bounding boxes.<br />
*** Then use Newton-Raphson iterations to get an accurate result.<br />
*** Finally check the validity of the solutions and check overlap.<br />
** More tests and improvements are needed.<br />
** Added the new CCI and CSI functions to brep_debug.cpp.<br />
* June 26<br />
** Improvements and bug fixing of curve-curve intersection<br />
*** Add tolerance value in the bounding box intersections.<br />
*** Check duplication before appending to the array x.<br />
*** In the Newton-Raphson iterations, if the inverse fails, we try another two directions.<br />
*** More work on the tolerance value to get a more accurate and correct result.<br />
** Add a test program for curve-curve intersections.<br />
* June 27<br />
** Continued improving curve-curve intersection<br />
*** Merge the overlap events that are continuous.<br />
*** Eliminate the intersection points that are inside the overlap events.<br />
*** Some special handling for linear curves.<br />
** Add another test for overlaps.<br />
* June 28<br />
** More work on CCI<br />
*** Assign values to m_a[1], m_A[1], etc. even if it's ccx_point event (according to openNURBS declarations in other/openNURBS/opennurbs_x.h)<br />
*** Fixed the wrong curve used in detecting overlaps.<br />
** Added more comments to document the intersection approaches.<br />
** Studied materials on curve-surface intersections and ready to get started.<br />
== Week 3 ==<br />
* July 1<br />
** Began to implement curve-surface intersections<br />
*** Use sub-division and Newton-Raphson iterations.<br />
*** It's similar to curve-curve intersections.<br />
* July 2<br />
** Added tests for curve-surface intersections.<br />
** Improved curve-surface intersections<br />
*** Check the endpoints of the line segment when computing its intersection with a boundary plane.<br />
*** Consider NaN.<br />
*** Add fabs() when calculating the line_t.<br />
** Fixed a typo in brep.c ("CS" for curve-surface rather than "PC").<br />
* July 3<br />
** Added another test for CSI (line & torus).<br />
** Continued improving curve-surface intersections.<br />
*** Reused surface tree - avoid generating the surface tree again and again.<br />
*** Added some special splitting machanism for polylines.<br />
*** Comparing doubles cannot use minus directly.<br />
*** If the starting point is good enough, we don't need Newton iterations.<br />
*** When merging, m_b should be consistent with m_a.<br />
*** Values of 3D and 2D spaces should have different tolerances. And consider the 2D tolerance when merging.<br />
* July 4<br />
** Started to work on surface-surface intersections (TDD)<br />
*** Did some clean up to the original code.<br />
*** Split the two steps (intersecting bounding boxes and triangular approximation).<br />
*** Dealt with single points, and checked validity of the solutions.<br />
** Using tests (csgbrep.g): brep sph.brep intersect tor.brep 0 0<br />
* July 5<br />
** Improve SSI<br />
*** Dealt with surface boundaries (using CSI).<br />
*** Some special handling for closed surfaces - added function closed_domain().<br />
*** Eliminated duplicated points using a naive approach.<br />
<br />
== Week 4 ==<br />
* July 8<br />
** Continued SSI<br />
*** Fixed bugs of triangle intersections - wrong line_normal for B, floating point issues (== is not sufficient), coincident planes cases, and calculate the barycentric coordination with ON_Solve2x2() in case that the inversion fails.<br />
*** Calculate max_dis using the length of bounding box diagonal, in case that both volumes are zero.<br />
** Modified brep_debug.cpp and test_ssi.cpp to deal with intersection points (use spheres to represent the points).<br />
* July 9<br />
** Uploaded some test images to this log with arb_intersect.g and csgbrep.g<br />
** Use 2D intersection tolerance with the 2D distances.<br />
** Linear fitting with the 2D intersection curves.<br />
* July 10<br />
** Perform Newton iterations to get more accurate surface-surface intersection points. (newton_ssi() in intersect.cpp)<br />
** Fixed a bug in triangle intersections raised by points_on_line.<br />
** More elegant SSI result display.<br />
** Did more tests and uploaded result images. (A problem comes out with the tests, as described below)<br />
* July 11<br />
** Worked on fitting the curves that SSI generates.<br />
*** Used an independent function to work on curve fitting.<br />
*** Added more fitting machanisms.<br />
*** Arc fitting - use ON_Curve::IsArc(). But tests seems that it cannot work well. I'll figure out why this happens.<br />
*** Ellipse fitting - ON_Curve::IsEllipse() cannot work because it only calls IsArc() in it. And it can not figure out when the curve is an elliptical arc. So I first wanted to use least square fitting provided by http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.7803, but found that openNURBS provided us with ON_GetConicEquationThrough6Points() and ON_IsConicEquationAnEllipse() which are very useful and decided to use them. The code works well, and these functions are also very helpful in other conic fittings (hyperbola, parabola).<br />
* July 12<br />
** Fixed a bug of fitting<br />
*** The original code cannot deal with elliptical arcs that cross the point where t=0 - Duplicate the ellipse curve to make its domain [0, 4*pi].<br />
** Tests and fixing the SSI code.<br />
*** Use a plane and an elliptic parabolic surface (epa). See the images below.<br />
*** Use max_dis_u (v, s, t) seperately as the scale of their domains may differ a lot. Before this, the result is totally a mess, but after this it's much better.<br />
*** Eliminate unnecessary collinear points on the polyline curves.<br />
*** Remove the arc fitting code, because ON_PolylineCurve::IsArc() always returns false. The elliptical arc fitting code below will work for this.<br />
== Week 5 ==<br />
* July 15<br />
** Normalized the intersection curves (use domain [0, 1]), and checked tangent events.<br />
** Checked domain parameters passed to ON_Intersect().<br />
** Used seaming curves to handle intersecting intersection curves.<br />
*** If two curves have points whose distance is less than max_dis (also consider the 2D distances), and they originally don't intersect (use curve-curve intersections), we generated a seaming curve to 'link' them together. Sometimes the seaming curves can be merged if they are continuous to one of the old curves.<br />
* July 16<br />
** Read papers to get ideas to handle overlaps in surface-surface intersections.<br />
** Discusses with other developers on the mailing list.<br />
** Two approaches come to mind:<br />
*** If we assume the two surfaces are C-infinity, we can use the theorem 3 in paper http://libgen.org/scimag1/10.1016/S0010-4485%252896%252900099-1.pdf (Thanks to Bryan Bishop). This can be reduced to several curve-surface overlap problems (already implemented) because the overlap region is bounded by surface boundaries.<br />
*** Otherwise, we need to get points inside the overlap region (using surfA->NormalAt(u,v) and surfB->NormalAt(s,t)), and then find the boundary (merge the triangles using the points as vertexes). These approach doesn't require continuity, but is very slow (too many bounding boxes and intersection points) and may la