[Bf-blender-cvs] [469fae8] soc-2014-nurbs: Merge branch 'soc-2014-nurbs' of git.blender.org:blender into soc-2014-nurbs
Jonathan deWerd
noreply at git.blender.org
Fri Jun 27 08:15:00 CEST 2014
Commit: 469fae8820bc21999e3abd5b753102cfbc54a97f
Author: Jonathan deWerd
Date: Fri Jun 27 02:14:07 2014 -0400
https://developer.blender.org/rB469fae8820bc21999e3abd5b753102cfbc54a97f
Merge branch 'soc-2014-nurbs' of git.blender.org:blender into soc-2014-nurbs
Conflicts:
source/blender/editors/io/io_rhino_import.cpp
===================================================================
===================================================================
diff --cc source/blender/editors/io/io_rhino_import.cpp
index aa31a1b,a4e1a20..7857487
--- a/source/blender/editors/io/io_rhino_import.cpp
+++ b/source/blender/editors/io/io_rhino_import.cpp
@@@ -80,86 -80,6 +80,89 @@@ static void import_ON_str(char *dest, O
wcstombs(dest, curve_name_unmanaged, n);
}
++<<<<<<< HEAD
+// Note: ignores first and last knots for Rhino compatibility. Returns:
+// (uniform) 0 <---| can't tell these two apart by knots alone.
+// #define CU_NURB_CYCLIC 1 <---| "periodic" is the hint that disambiguates them.
+// #define CU_NURB_ENDPOINT 2
+// #define CU_NURB_BEZIER 4
+static int analyze_knots(float *knots, int num_knots, int order, bool periodic, float tol=.001) {
+ float first = knots[1];
+ float last = knots[num_knots-2];
+
+ bool start_clamped = true;
+ for (int i=2; i<order; i++) {
+ if (abs(knots[i]-first)>tol) {start_clamped = false; break;}
+ }
+ bool end_clamped = true;
+ for (int i=num_knots-3; i>=num_knots-order; i--) {
+ if (abs(knots[i]-last)>tol) {end_clamped = false; break;}
+ }
+ bool bezier = start_clamped && end_clamped;
+ bool unif_bezier = bezier;
+ if (bezier) {
+ float jump = knots[order]-knots[order-1];
+ for (int i=order; i<num_knots-order; i+=2) {
+ if (abs(knots[i]-knots[i+1])>tol) {
+ bezier = false;
+ unif_bezier = false;
+ break;
+ }
+ if (abs(knots[i]-knots[i-1]-jump)>tol) {
+ unif_bezier = false;
+ }
+ }
+ }
+ bool unif = !start_clamped && !end_clamped && !bezier;
+ if (unif) {
+ float jump = knots[1] - knots[0];
+ for (int i=2; i<num_knots; i++) {
+ if (abs(knots[i]-knots[i-1]-jump)>tol) {
+ unif = false;
+ break;
+ }
+ }
+ }
+ bool unif_clamped = !unif && !bezier && start_clamped && end_clamped;
+ if (unif_clamped) {
+ float jump = knots[order]-knots[order-1];
+ for (int i=order; i<=num_knots-order; i++) {
+ if (abs(knots[i]-knots[i-1]-jump)>tol) {
+ unif_clamped = false;
+ break;
+ }
+ }
+ }
+
+ if (bezier) {
+ BLI_assert(unif_bezier);
+ return CU_NURB_BEZIER;
+ }
+ if (unif) {
+ return periodic? CU_NURB_CYCLIC : 0;
+ }
+ if (unif_clamped) {
+ return CU_NURB_ENDPOINT;
+ }
+ BLI_assert(false /* Can't tell curve type from knots */ );
+ return 0;
+}
+
+static void normalize_knots(float *knots, int num_knots) {
+ float tol = .001;
+ int i=0;
+ for (; i<num_knots; i++) {
+ if (abs(knots[i]-0)>tol) break;
+ }
+ if (i==num_knots) return;
+ float mult = 1.0 / knots[i];
+ for (; i<num_knots; i++) {
+ knots[i] *= mult;
+ }
+}
+
++=======
++>>>>>>> 8c8a5a6dc4a958732fc5035fcf073879bb871e22
/****************************** Curve Import *********************************/
static float null_loc[] = {0,0,0};
static float null_rot[] = {0,0,0};
@@@ -241,6 -161,10 +244,13 @@@ static void rhino_import_nurbscurve(bCo
nu->pntsv = 1;
nu->orderu = nc->Order();
nu->orderv = 1;
++<<<<<<< HEAD
++=======
+ if (nc->IsPeriodic())
+ nu->flagu = CU_NURB_CYCLIC;
+ if (nc->IsClamped())
+ nu->flagu = CU_NURB_ENDPOINT;
++>>>>>>> 8c8a5a6dc4a958732fc5035fcf073879bb871e22
BLI_assert(nu->pntsu + nu->orderu - 2 == nc->KnotCount());
bp = nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * ((nu->pntsu) * 1), "rhino_imported_NURBS_curve_points");
nu->knotsu = (float *)MEM_callocN(sizeof(float) * ((nu->pntsu+nu->orderu) * 1), "rhino_imported_NURBS_curve_points");
@@@ -259,8 -183,6 +269,11 @@@
nu->knotsu[i] = nc->Knot(i-1);
}
nu->knotsu[i] = nu->knotsu[i-1];
++<<<<<<< HEAD
+ nu->flagu = analyze_knots(nu->knotsu, nu->pntsu+nu->orderu, nu->orderu, nc->IsPeriodic());
+ normalize_knots(nu->knotsu, nu->pntsu+nu->orderu);
++=======
++>>>>>>> 8c8a5a6dc4a958732fc5035fcf073879bb871e22
editnurb = object_editcurve_get(obedit);
BLI_addtail(editnurb, nu);
@@@ -613,12 -537,6 +632,11 @@@ static void rhino_import_surface(bConte
rhino_import_nurbs_surf(C, ns, obj, attrs, newobj);
delete ns;
}
+ did_handle = true;
+ }
+ if (!did_handle) {
+ char surf_name[MAX_ID_NAME];
-
- printf("couldn't handle ")
++ printf("couldn't handle ");
}
}
More information about the Bf-blender-cvs
mailing list