[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16909] branches/nurbs/blender: - Refactored Subdivide to use the same interface style as Degree reduce and increase .

Emmanuel Stone emmanuel.stone at gmail.com
Sat Oct 4 02:00:56 CEST 2008


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

Log Message:
-----------
- Refactored Subdivide to use the same interface style as Degree reduce and increase.
- UI tweaks, curve options now different from surfaces

Modified Paths:
--------------
    branches/nurbs/blender/intern/nurbana/extern/nurbana.h
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.cpp
    branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.h
    branches/nurbs/blender/intern/nurbana/intern/libNurbana.cpp
    branches/nurbs/blender/source/blender/include/butspace.h
    branches/nurbs/blender/source/blender/src/buttons_editing.c
    branches/nurbs/blender/source/blender/src/editcurve.c

Modified: branches/nurbs/blender/intern/nurbana/extern/nurbana.h
===================================================================
--- branches/nurbs/blender/intern/nurbana/extern/nurbana.h	2008-10-03 23:36:02 UTC (rev 16908)
+++ branches/nurbs/blender/intern/nurbana/extern/nurbana.h	2008-10-04 00:00:56 UTC (rev 16909)
@@ -142,7 +142,7 @@
 
 extern nbReal3_ptr NRB_GenerateNormals(NurbanaObj_ptr nop);
 
-extern void NRB_Subdivide(NurbanaObj_ptr nop,nbReal subdividePositionU, nbReal subdividePositionV);
+extern void NRB_Subdivide(NurbanaObj_ptr nop,int subdivideU, int subdivideV);
 extern void NRB_Refine(NurbanaObj_ptr nop,nbReal *X, int r, int UV);
 
 extern void NRB_DegreeElevate(NurbanaObj_ptr nop,int Uinc, int Vinc);

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.cpp	2008-10-03 23:36:02 UTC (rev 16908)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.cpp	2008-10-04 00:00:56 UTC (rev 16909)
@@ -480,168 +480,99 @@
 //} //eof NURBS_Knot::_Insert()
 //
 //
-void NURBS_Knot::Subdivide(Object_NURBS *obj,nbReal subdividePositionU, nbReal subdividePositionV) {
+void NURBS_Knot::Subdivide(Object_NURBS *obj,int subdivideU, int subdivideV) {
 	int		i,n;
 	nbReal	*KV;
-	int kpu,kpv;
+
 	int numKnotsU = obj -> Length(0) + obj -> Order(0) - 1;
 	int numKnotsV = obj -> Length(1) + obj -> Order(1) - 1;
 
-	//if(subdividePositionU < 0 || subdividePositionV < 0) // do i still want to do it this way?
-	//{
-	//	subdividePositionU = 0.5;
-	//	subdividePositionV = 0.5;
-	//}
 
-	kpu = (int)(numKnotsU*subdividePositionU);
-	kpv = (int)(numKnotsV*subdividePositionV);
-
-
 	// Subdivide U
-	if (obj -> Length(0) > 1) {
+	while (subdivideU--){
+		if(obj -> Length(0) > 1) {
 
-		int knotLen;
-		if(obj->Cyclic(0)) { // cyclic in U
-			knotLen = (obj -> Length(0) + (obj -> Order(0)*2) -1);
-		}
-		else { // not cyclic in U
-			knotLen = obj -> Length(0) + (obj -> Order(0));
-			
-		}
+			int knotLen;
+			if(obj->Cyclic(0)) { // cyclic in U
+				knotLen = (obj -> Length(0) + (obj -> Order(0)*2) -1);
+			}
+			else { // not cyclic in U
+				knotLen = obj -> Length(0) + (obj -> Order(0));
+				
+			}
 
-		if(*obj->_KnotTypeUV[0] == NURBS_KV_Open) { // Open = endtied
-			//#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
-			KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(knotLen),"Subdivide() KVu");
-			for (i= n= 0; i < knotLen -1; i++) { //FIXME adjust for cyclic
+			if(*obj->_KnotTypeUV[0] == NURBS_KV_Open) { // Open = endtied
+				//#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
+				KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(knotLen),"Subdivide() KVu");
+				for (i= n= 0; i < knotLen -1; i++) { //FIXME adjust for cyclic
+					KV[n++]= obj -> KnotVector(0)[i];
+					if (obj -> KnotVector(0)[i+1] - obj -> KnotVector(0)[i])
+							KV[n++]= (obj -> KnotVector(0)[i+1] + obj -> KnotVector(0)[i])/2.0;
+				} //eof
 				KV[n++]= obj -> KnotVector(0)[i];
-				//if(i==5)// FIXME  
-				//if (kpu == i || ((kpu < 0) && obj -> KnotVector(0)[i+1] - obj -> KnotVector(0)[i]))
-				if (obj -> KnotVector(0)[i+1] - obj -> KnotVector(0)[i])
+				_Insert(obj,0,KV,n);
+				//  MEM_freeN(KV);
+			
+			}
+			else if(*obj->_KnotTypeUV[0] == NURBS_KV_Periodic) { // periodic = cyclic
+				//if(obj->Cyclic(0)) { // not cyclic
+				KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(knotLen),"Subdivide() KVu");
+				for (i= n= 0; i < knotLen - 1; i++) { //FIXME adjust for cyclic
+					KV[n++]= obj -> KnotVector(0)[i];
+					if(i > 3 && i<  knotLen - 3 )			
+					{
+						printf("i = %d\n",i);
 						KV[n++]= (obj -> KnotVector(0)[i+1] + obj -> KnotVector(0)[i])/2.0;
-			} //eof
-			KV[n++]= obj -> KnotVector(0)[i];
-			_Insert(obj,0,KV,n);
-			//  MEM_freeN(KV);
-		
-		}
-		else if(*obj->_KnotTypeUV[0] == NURBS_KV_Periodic) { // periodic = cyclic
-			//if(obj->Cyclic(0)) { // not cyclic
-			KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(knotLen),"Subdivide() KVu");
-			for (i= n= 0; i < knotLen - 1; i++) { //FIXME adjust for cyclic
+					}
+				} //eof
 				KV[n++]= obj -> KnotVector(0)[i];
-				//if(i==kpu)// FIXME  
-				//if (obj -> KnotVector(0)[i+1] - obj -> KnotVector(0)[i])
-				//if (i < obj -> Length(0) && i > (obj -> Order(0)-1) && obj -> KnotVector(0)[i+1] - obj -> KnotVector(0)[i])
-					//if (i < obj -> Length(0) && obj -> KnotVector(0)[i+1] - obj -> KnotVector(0)[i])
-				//if (i == kpu || ((kpu <0 ) && i > (obj -> Order(0)-1) && i < (knotLen-obj -> Order(0)-1) ))//obj -> Length(0)+6))//knotLen-4)
-			//	if (i == kpu || ((kpu <0 ) && i > (obj -> Order(0)-1) && i < (knotLen -(obj -> Order(0)-0)) ))//obj -> Length(0)+6))//knotLen-4)
-				if(i > 3 && i<  knotLen - 3 )			
-				{
-					printf("i = %d\n",i);
-					KV[n++]= (obj -> KnotVector(0)[i+1] + obj -> KnotVector(0)[i])/2.0;
-				}
-			} //eof
-			KV[n++]= obj -> KnotVector(0)[i];
-			_Insert(obj,0,KV,n);
-			//  MEM_freeN(KV);
-		}
-	} //fi
+				_Insert(obj,0,KV,n);
+				//  MEM_freeN(KV);
+			}
+		} //fi
+	}// while
 
 	// Subdivide V
-	if (obj -> Length(1) > 1) {
+	while(subdivideV--){
+		if (obj -> Length(1) > 1) {
 
-		int knotLen;
-		if(obj->Cyclic(1)) { // cyclic in V	
-			knotLen = (obj -> Length(1) + (obj -> Order(1)*2) -1);
-		}
-		else { // not cyclic in V
-			knotLen = obj -> Length(1) + (obj -> Order(1));
-		}
-		if(*obj->_KnotTypeUV[1] == NURBS_KV_Open) { // Open = endtied
-			//#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
-			KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(knotLen),"Subdivide() KVu");
-			for (i= n= 0; i < knotLen -1; i++) { //FIXME adjust for cyclic
-				KV[n++]= obj -> KnotVector(1)[i];
-				//if(i==5)// FIXME  
-				if (obj -> KnotVector(1)[i+1] - obj -> KnotVector(1)[i])
-					KV[n++]= (obj -> KnotVector(1)[i+1] + obj -> KnotVector(1)[i])/2.0;
-			} //eof
-			KV[n++]= obj -> KnotVector(1)[i];
-			_Insert(obj,1,KV,n);
-			//  MEM_freeN(KV);
-
-		}
-		else if(*obj->_KnotTypeUV[1] == NURBS_KV_Periodic) { // periodic = cyclic
-			KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(knotLen),"Subdivide() KVu");
-			for (i= n= 0; i < knotLen - 1; i++) { //FIXME adjust for cyclic
-				KV[n++]= obj -> KnotVector(1)[i];
-				//if(i==kpv)// FIXME  
-				//if (obj -> KnotVector(1)[i+1] - obj -> KnotVector(1)[i])
-				//	if (i < obj -> Length(1) && i > obj -> Order(1) && obj -> KnotVector(1)[i+1] - obj -> KnotVector(1)[i])
-				if (i > 2 && i < obj -> Length(1)+1)//knotLen-4)
-					KV[n++]= (obj -> KnotVector(1)[i+1] + obj -> KnotVector(1)[i])/2.0;
-				
-			} //eof
-			KV[n++]= obj -> KnotVector(1)[i];
-			_Insert(obj,1,KV,n);
-			//  MEM_freeN(KV);
-		}
-		/*
-		if(*obj->_KnotTypeUV[1] == NURBS_KV_Open) {
-			if(obj->Cyclic(1)) { // not cyclic
-				KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(obj -> Length(1) + (obj -> Order(1)*2) -1),"Subdivide() KVv");
-				for (i= n= 0; i < obj -> Length(1) + (obj -> Order(1)*2) - 2; i++) { 
-					//#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
-					KV[n++]= obj -> KnotVector(1)[i];
-					//if(i==5)// FIXME 
-					if (obj -> KnotVector(1)[i+1] - obj -> KnotVector(1)[i])
-						KV[n++]= (obj -> KnotVector(1)[i+1] + obj -> KnotVector(1)[i])/2.0;
-				} //eof
-				KV[n++]= obj -> KnotVector(1)[i];
-				_Insert(obj,1,KV,n);
-				//MEM_freeN(KV); eman FIXME
+			int knotLen;
+			if(obj->Cyclic(1)) { // cyclic in V	
+				knotLen = (obj -> Length(1) + (obj -> Order(1)*2) -1);
 			}
-			else {
-				KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(obj -> Length(1) + obj -> Order(1)),"Subdivide() KVv");
-				for (i= n= 0; i < obj -> Length(1) + obj -> Order(1) - 1; i++) { //#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
-					KV[n++]= obj -> KnotVector(1)[i];
-					//if(i==5)// FIXME 
-					if (obj -> KnotVector(1)[i+1] - obj -> KnotVector(1)[i])
-						KV[n++]= (obj -> KnotVector(1)[i+1] + obj -> KnotVector(1)[i])/2.0;
-				} //eof
-				KV[n++]= obj -> KnotVector(1)[i];
-				_Insert(obj,1,KV,n);
-				//MEM_freeN(KV); eman FIXME
+			else { // not cyclic in V
+				knotLen = obj -> Length(1) + (obj -> Order(1));
 			}
-		}
-		else if(*obj->_KnotTypeUV[1] == NURBS_KV_Periodic) {
-			if(obj->Cyclic(1)) { // not cyclic
-				//KV= (nbReal*)malloc(sizeof(nbReal)*2*(obj -> Length(1) + obj -> Order(1)));
-				KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(obj -> Length(1) + (obj -> Order(1)*2) -1),"Subdivide() KVv");
-				for (i= n= 0; i < obj -> Length(1) + (obj -> Order(1)*2) - 2; i++) {
+			if(*obj->_KnotTypeUV[1] == NURBS_KV_Open) { // Open = endtied
+				//#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
+				KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(knotLen),"Subdivide() KVu");
+				for (i= n= 0; i < knotLen -1; i++) { //FIXME adjust for cyclic
 					KV[n++]= obj -> KnotVector(1)[i];
-					//if(i==5)// FIXME 
 					if (obj -> KnotVector(1)[i+1] - obj -> KnotVector(1)[i])
 						KV[n++]= (obj -> KnotVector(1)[i+1] + obj -> KnotVector(1)[i])/2.0;
 				} //eof
 				KV[n++]= obj -> KnotVector(1)[i];
 				_Insert(obj,1,KV,n);
+				//  MEM_freeN(KV);
+
 			}
-			else {
-				//KV= (nbReal*)malloc(sizeof(nbReal)*2*(obj -> Length(1) + obj -> Order(1)));
-				KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(obj -> Length(1) + obj -> Order(1)),"Subdivide() KVv");
-				for (i= n= 0; i < obj -> Length(1) + obj -> Order(1) - 1; i++) {
+			else if(*obj->_KnotTypeUV[1] == NURBS_KV_Periodic) { // periodic = cyclic
+				KV= (nbReal*)MEM_callocN(sizeof(nbReal)*2*(knotLen),"Subdivide() KVu");
+				for (i= n= 0; i < knotLen - 1; i++) { //FIXME adjust for cyclic
 					KV[n++]= obj -> KnotVector(1)[i];
-					if(i==kpv)// FIXME 
+
 					//if (obj -> KnotVector(1)[i+1] - obj -> KnotVector(1)[i])
+					//	if (i < obj -> Length(1) && i > obj -> Order(1) && obj -> KnotVector(1)[i+1] - obj -> KnotVector(1)[i])
+					if (i > 2 && i < obj -> Length(1)+1)//knotLen-4)
 						KV[n++]= (obj -> KnotVector(1)[i+1] + obj -> KnotVector(1)[i])/2.0;
+					
 				} //eof
 				KV[n++]= obj -> KnotVector(1)[i];
 				_Insert(obj,1,KV,n);
+				//  MEM_freeN(KV);
 			}
-		}
-*/
-	} //fi
+		} //fi
+	} //while
 } //eof NURBS_Knot::Subdivide()
 
 

Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Knot.h
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list