[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16911] branches/nurbs/blender: - Cleaned up some comments

Emmanuel Stone emmanuel.stone at gmail.com
Sat Oct 4 03:18:21 CEST 2008


Revision: 16911
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16911
Author:   eman
Date:     2008-10-04 03:18:05 +0200 (Sat, 04 Oct 2008)

Log Message:
-----------
- Cleaned up some comments
- Made curves default to endtied/clamped after converting from cyclic

Modified Paths:
--------------
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp
    branches/nurbs/blender/source/blender/src/editcurve.c

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp	2008-10-04 00:39:33 UTC (rev 16910)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp	2008-10-04 01:18:05 UTC (rev 16911)
@@ -19,12 +19,8 @@
 	orderV = obj->Order(1);
 
 	// Memory Allocation
-	// Resize Surface
-	// obj -> SetLength(obj -> Length(0)+(obj -> Length(0)-(orderU-1))*Uinc,pntsV+(pntsV-(orderV-1))*Vinc);
 	int newCtlPtsSize = (pntsU+(pntsU-(orderU-1))*Uinc)*(pntsV+(pntsV-(orderV-1)));
-//	newCtlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*pntsU+(pntsU-(orderU-1))*Uinc*pntsV+(pntsV-(orderV-1))*Vinc,"NURBS_Degree::Elevate newCtlPts");
 
-
 	newPntsU = obj -> Length(0)+(obj -> Length(0)-(orderU-1))*Uinc;
 	newPntsV = pntsV+(pntsV-(orderV-1))*Vinc;
 	newCtlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*newPntsU*newPntsV,"NURBS_Degree::Elevate newCtlPts");
@@ -43,8 +39,7 @@
 	ebpts = (Point3d*)MEM_callocN(sizeof(Point3d)*64,"NURBS_Degree::Elevate ebpts");
 	UV *= (orderU > orderV) ? orderU : orderV;
 	Coef = (nbReal*)MEM_callocN(sizeof(nbReal)*(UV),"NURBS_Degree::Elevate Coef");
-
-	//UV = (pntsU+(pntsU-(orderU-1))*Uinc) > (pntsV+(pntsV-(orderV-1))*Vinc) ? pntsU+(pntsU-(orderU-1))*Uinc : pntsV+(pntsV-(orderV-1))*Vinc;
+	
 	UV = (pntsU+(pntsU-(orderU-1))*Uinc) > (pntsV+(pntsV-(orderV-1))*Vinc) ? pntsU+(pntsU-(orderU-1))*Uinc : pntsV+(pntsV-(orderV-1))*Vinc;
 	Qw = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate Qw");
 	Pts = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate Pts");
@@ -55,7 +50,7 @@
 	FnlKVV = (nbReal*)MEM_callocN(sizeof(nbReal)*(pntsV+(pntsV-(orderV-1))*Vinc+Vinc+orderV),"NURBS_Degree::Elevate FnlKVV");
 	Uh = (nbReal*)MEM_callocN(sizeof(nbReal)*((pntsU+(pntsU-(orderU-1))*Uinc+Uinc+orderU) > (pntsV+(pntsV-(orderV-1))*Vinc+Vinc+orderV) ? pntsU+(pntsU-(orderU-1))*Uinc+Uinc+orderU : pntsV+(pntsV-(orderV-1))*Vinc+Vinc+orderV),"NURBS_Degree::Elevate Uh");
 
-	for(UV = 1; UV >= 0; UV--) { // FIXME put in check for curve? eman
+	for(UV = 1; UV >= 0; UV--) { 
 			Inc = UV ? Vinc : Uinc;
 
 		if(Inc) {
@@ -246,7 +241,7 @@
 						// Load the Knot ua
 						for(i= 0; i < ph - oldr; i++) {
 							Uh[kind]= ua;
-							kind= kind++; // FIXME eman
+							kind= kind++;
 						} //eof
 					} //fi
 
@@ -298,9 +293,6 @@
 				if(UV) {
 					// V Directional Curves
 					for(i = 0; i < Npts; i++) {
-						//if((i+Npts*Curve) >= fnlPtsSize)
-						//	printf("o noes\n");
-						//int indx = i+Npts*Curve;
 						int indx = i*(pntsU+(pntsU-(orderU-1))*Uinc)+Curve;
 						FnlPts[indx].x = Pts[i].x;
 						FnlPts[indx].y = Pts[i].y;
@@ -314,21 +306,17 @@
 						//newCtlPts[i*pntsU+Curve].y = Pts[i].y;
 						//newCtlPts[i*pntsU+Curve].z = Pts[i].z;
 						//newCtlPts[i*pntsU+Curve].H = Pts[i].H;
-						printf("V FnlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",indx,FnlPts[indx].x,FnlPts[indx].y,FnlPts[indx].z,FnlPts[indx].H);
+						//printf("V FnlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",indx,FnlPts[indx].x,FnlPts[indx].y,FnlPts[indx].z,FnlPts[indx].H);
 					} //eof
 				} else {
 					// U Directional Curves
 					for(i= 0; i < Npts; i++) {
-						//if((i*(pntsV+(pntsV-(orderV-1))*Vinc)+Curve) >= fnlPtsSize)
-						//	printf("o noes\n");
 						int indx = i+Npts*Curve;
-						//int indx = i*(pntsV+(pntsV-(orderV-1))*Vinc)+Curve;
 						FnlPts[indx].x = Pts[i].x;
 						FnlPts[indx].y = Pts[i].y;
 						FnlPts[indx].z = Pts[i].z;
 						FnlPts[indx].H = Pts[i].H;
-						printf("U FnlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",indx,FnlPts[indx].x,FnlPts[indx].y,FnlPts[indx].z,FnlPts[indx].H);
-						
+						//printf("U FnlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",indx,FnlPts[indx].x,FnlPts[indx].y,FnlPts[indx].z,FnlPts[indx].H);
 					} //eof
 				} //fi
 			} //eof (Curves)
@@ -352,8 +340,8 @@
 	if(Vinc) {
 		obj -> Length(1,FnlLV);
 		obj -> ReplaceKnotVector(1, FnlKVV);
-		for(i = 0; i < obj -> Length(1)+obj -> Order(1)+Vinc; i++)
-			printf("kvv[%d]: %0.3f\n",i, FnlKVV[i]);
+		//for(i = 0; i < obj -> Length(1)+obj -> Order(1)+Vinc; i++)
+		//	printf("kvv[%d]: %0.3f\n",i, FnlKVV[i]);
 		//  obj -> KnotVector(1)[i] = FnlKVV[i];
 		obj -> Order(1,obj -> Order(1)+Vinc);
 	}
@@ -362,8 +350,8 @@
 	if(Uinc) {
 		obj -> Length(0,FnlLU);
 		obj -> ReplaceKnotVector(0,FnlKVU);
-		for(i = 0; i < obj -> Length(0)+obj -> Order(0)+Uinc; i++)
-			printf("kvu[%d]: %f\n",i, FnlKVU[i]);
+		//for(i = 0; i < obj -> Length(0)+obj -> Order(0)+Uinc; i++)
+		//printf("kvu[%d]: %f\n",i, FnlKVU[i]);
 		//  obj -> KnotVector(0)[i] = FnlKVU[i];
 		obj -> Order(0,obj -> Order(0)+Uinc);
 	}
@@ -371,11 +359,6 @@
 
 	// Copy Final Points into Original Points
 	if(Uinc || Vinc) {
-		//obj -> ReplaceCtlPts(FnlPts);
-		/*for(i = 0; i < obj -> Length(0) * obj -> Length(1); i++) {
-			printf("ctlpts[%d]: %.3f,%.3f,%.3f:%.3f\n",i,FnlPts[i].z,FnlPts[i].y,FnlPts[i].z,FnlPts[i].H);
-		}*/
-
 		// use new lengths here, not pntsU and pntsV
 		for(i = 0; i < obj -> Length(0) * obj -> Length(1); i++) {
 
@@ -383,8 +366,7 @@
 			newCtlPts[i].y= FnlPts[i].y;
 			newCtlPts[i].z= FnlPts[i].z;
 			newCtlPts[i].H= FnlPts[i].H;
-			printf("newCtlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",i,newCtlPts[i].x,newCtlPts[i].y,newCtlPts[i].z,newCtlPts[i].H);
-
+			//printf("newCtlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",i,newCtlPts[i].x,newCtlPts[i].y,newCtlPts[i].z,newCtlPts[i].H);
 		}
 		obj -> ReplaceCtlPts(newCtlPts);
 	}
@@ -409,9 +391,16 @@
 	nbReal tni; // (1 - t)^i
 
 	// handle the special cases to avoid domain problem with pow
-	if((t == 0) && (i == 0)) ti= 1.0; else ti= pow(t,i);
+	if((t == 0) && (i == 0)) 
+		ti= 1.0; 
+	else 
+		ti= pow(t,i);
 
-	if((n == i) && (t == 1)) tni= 1.0; else tni= pow((1-t),(n-i));
+	if((n == i) && (t == 1)) 
+		tni= 1.0; 
+	else tni= 
+		pow((1-t),(n-i));
+
 	return( NurbanaMath::Comb(n,i)*ti*tni ); // calculate Bernstein basis function
 }
 
@@ -515,9 +504,7 @@
 
 	TOL= 100.0;
 
-
 	// Memory Allocations
-
 	UV= (obj -> Length(0) > obj -> Length(1) ? obj -> Length(0) : obj -> Length(1));
 	Pts= (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Reduce ");
 	Temp= (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Reduce ");
@@ -652,6 +639,7 @@
 						error[a]= error[a]+MaxErr;
 						if(error[a] > TOL) {
 							// Curve not degree reducible
+							// FIXME eman - Print Blender Error for this
 							printf("bail!\n");
 							return;
 						} //fi
@@ -702,6 +690,7 @@
 									// These knot spans were affected
 									error[ii]= error[ii] + Br;
 									if(error[ii] > TOL) {
+										// FIXME eman - Print Blender Error for this
 										printf("bail: %f\n",error[ii]);
 										return;  // Curve not degree reducible
 									}
@@ -789,8 +778,9 @@
 						FnlPts[indx].y= Pts[i].y;
 						FnlPts[indx].z= Pts[i].z;
 						FnlPts[indx].H= Pts[i].H;
-						printf("U FnlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",indx,FnlPts[indx].x,FnlPts[indx].y,FnlPts[indx].z,FnlPts[indx].H);
+						//printf("U FnlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",indx,FnlPts[indx].x,FnlPts[indx].y,FnlPts[indx].z,FnlPts[indx].H);
 
+						// will need to do something like this if we allow simultaenous reduction in U and V
 						//// Update Original because we know U is just tacked onto the end of the array and
 						//// may be needed for V directional elevation if this is a U and V reduction
 						//obj -> CtlPts()[i*obj -> Length(1)+Curve].x= Pts[i].x;
@@ -829,30 +819,14 @@
 	} //fi
 
 
-	//// Copy Final Points into Original Points
+	// Copy Final Points into Original Points - no need to realloc as array will be smaller
 	for(i= 0; i < obj -> Length(0) * obj -> Length(1); i++) {
 		obj -> CtlPts()[i].x= FnlPts[i].x;
 		obj -> CtlPts()[i].y= FnlPts[i].y;
 		obj -> CtlPts()[i].z= FnlPts[i].z;
 		obj -> CtlPts()[i].H= FnlPts[i].H;
 	} //eof
-	//obj->ReplaceCtlPts(FnlPts);
-	// Copy Final Points into Original Points
-	//if(Udec || Vdec) {
-	//	// use new lengths here, not pntsU and pntsV
-	//	for(i = 0; i < obj -> Length(0) * obj -> Length(1); i++) {
 
-	//		newCtlPts[i].x= FnlPts[i].x;
-	//		newCtlPts[i].y= FnlPts[i].y;
-	//		newCtlPts[i].z= FnlPts[i].z;
-	//		newCtlPts[i].H= 1; //FIXME eman
-	//		printf("newCtlPts[%d]: %.3f,%.3f,%.3f:%.3f\n",i,newCtlPts[i].z,newCtlPts[i].y,newCtlPts[i].z,newCtlPts[i].H);
-
-	//	}
-	//	obj -> ReplaceCtlPts(newCtlPts);
-	//}
-
-
 	// Free Memory
 	MEM_freeN(Pts);
 	MEM_freeN(Temp);

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp	2008-10-04 00:39:33 UTC (rev 16910)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp	2008-10-04 01:18:05 UTC (rev 16911)
@@ -15,8 +15,6 @@
 		Surface(obj, resU , resV * Vnpts , dim, buffer, NULL, NULL, obj -> Sum(), 0, 0, 1);
 	else
 		Surface(obj,resU, resV , dim, buffer, NULL, NULL, obj -> Sum(), 0, 0, 1);
-
-	//IsoLines(obj);
 }
 
 void	NURBS_Generate::IsoLines(Object_NURBS *obj, nbReal* buffer) {
@@ -78,9 +76,6 @@
 		recalc = (obj -> Change(Change) != Unpts+Vnpts+OrderU+OrderV+TessU+TessV+CyclicU+CyclicV);
 	obj -> Change(Change,Unpts+Vnpts+OrderU+OrderV+TessU+TessV+CyclicU+CyclicV);
 
-	// recalc = 1;//FIXME
-	// ("recalc: %d\n",recalc);
-
 	// Recalculate Basis Functions
 	if(recalc) {
 
@@ -152,12 +147,7 @@
 					TssPts4[Index+m].x = TssPts4[Index+m].y= TssPts4[Index+m].z= TssPts4[Index+m].a=0;
 				else
 					TssPts3[Index+m].x = TssPts3[Index+m].y= TssPts3[Index+m].z= 0;
-
-				//printf("m=%d\n",Index+m);
-				//if(Index +m > 6)
-				//	printf("break - Hammertime!\n");
 		
-
 				//printf("Basis_U[%d][%d]: %.3f\n", i, k, BasisU[i][k]);
 				for(l = 0; l < Vnpts + extraPntsV; l++) {
 					//	
@@ -190,28 +180,15 @@
 										tiltBuffer[Index+m] += (obj -> CtlPts()[j].alfa*BasisResult);
 									if(radiusBuffer)
 										radiusBuffer[Index+m] += (obj -> CtlPts()[j].radius*BasisResult);
-
-									//float cutoff = 0.0001;
-								//	if(TssPts3[Index+m].x < cutoff && TssPts3[Index+m].y < cutoff && TssPts3[Index+m].z > -cutoff && TssPts3[Index+m].x > -cutoff && TssPts3[Index+m].y > -cutoff && TssPts3[Index+m].z > -cutoff)
-								//		printf("Oh NOES!\n");
-								
+			
 								}
 							}
 						}
 					} else {
-			//			//j += Unpts;//Vnpts;
-					//	printf("hmmm\n");
 					}
 				}
 				//printf(" m %d \n",m);
-				if(dim != 4)
-				{
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list