[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12629] branches/nurbs/blender: This is an interim commit, not everything is working yet.
Emmanuel Stone
emmanuel.stone at gmail.com
Mon Nov 19 22:12:30 CET 2007
Revision: 12629
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12629
Author: eman
Date: 2007-11-19 22:12:30 +0100 (Mon, 19 Nov 2007)
Log Message:
-----------
This is an interim commit, not everything is working yet.
- Incremental calculations (faster than recalculating tesselation points from scratch every time.
- Added Degree Elevate/Reduce. Currently broken, but want to commit what I have so far.
Modified Paths:
--------------
branches/nurbs/blender/intern/nurbana/extern/nurbana.h
branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp
branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp
branches/nurbs/blender/intern/nurbana/intern/Object_Base.cpp
branches/nurbs/blender/intern/nurbana/intern/Object_NURBS.cpp
branches/nurbs/blender/intern/nurbana/intern/Object_NURBS.h
branches/nurbs/blender/intern/nurbana/intern/libNurbana.cpp
branches/nurbs/blender/source/blender/blenkernel/intern/curve.c
branches/nurbs/blender/source/blender/include/butspace.h
branches/nurbs/blender/source/blender/makesdna/DNA_curve_types.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 2007-11-19 20:13:14 UTC (rev 12628)
+++ branches/nurbs/blender/intern/nurbana/extern/nurbana.h 2007-11-19 21:12:30 UTC (rev 12629)
@@ -99,7 +99,7 @@
typedef nbReal3* nbReal3_ptr;
typedef void* NurbanaObj_ptr; // to hide pointer to C++ object in C space
-extern NurbanaObj_ptr NRB_addObject(Point3d** CtlPts, short* numCPu, short* numCPv, short* orderU, short* orderV, nbReal** knotsU, nbReal** knotsV, short* cyclicU, short* cyclicV, short* knottypeu, short* knottypev, short* resolu, short* resolv, short* isores, short* isoden) ;
+extern NurbanaObj_ptr NRB_addObject(Point3d** CtlPts, short* numCPu, short* numCPv, short* orderU, short* orderV, nbReal** knotsU, nbReal** knotsV, short* cyclicU, short* cyclicV, short* knottypeu, short* knottypev, short* resolu, short* resolv, short* isores, short* isoden, short* isovis) ;
extern NurbanaObj_ptr NRB_CreatePrimitive(unsigned char type);
extern void NRB_removeObject(NurbanaObj_ptr nop);
@@ -133,7 +133,11 @@
extern nbReal3_ptr NRB_GenerateNormals(NurbanaObj_ptr nop);
extern void NRB_Subdivide(NurbanaObj_ptr nop,nbReal subdividePositionU, nbReal subdividePositionV);
+extern void NRB_Refine(NurbanaObj_ptr nop,nbReal *X, int r, int UV);
+extern void NRB_DegreeElevate(NurbanaObj_ptr nop,int Uinc, int Vinc);
+extern void NRB_DegreeReduce(NurbanaObj_ptr nop,int Udec, int Vdec);
+
extern void NRB_Print(NurbanaObj_ptr nop);
extern void NRB_Echo();
Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp 2007-11-19 20:13:14 UTC (rev 12628)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Degree.cpp 2007-11-19 21:12:30 UTC (rev 12629)
@@ -15,26 +15,25 @@
obj -> SetLength(obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc,obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc);
UV = (obj -> Order(0) > obj -> Order(1)) ? obj -> Order(0) : obj -> Order(1);
- bpts = (Point3d*)malloc(sizeof(Point3d)*64);
- Coefb = (float*)malloc(sizeof(float)*UV);
- Nextbpts = (Point3d*)malloc(sizeof(Point3d)*UV);
+ bpts = (Point3d*)MEM_callocN(sizeof(Point3d)*64,"NURBS_Degree::Elevate "); //FIXME CHECKME 64???
+ Coefb = (float*)MEM_callocN(sizeof(float)*UV,"NURBS_Degree::Elevate ");
+ Nextbpts = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate ");
UV = (obj -> Order(0)+Uinc > obj -> Order(1)+Vinc) ? obj -> Order(0)+Uinc : obj -> Order(1)+Vinc;
- ebpts = (Point3d*)malloc(sizeof(Point3d)*64);
+ ebpts = (Point3d*)MEM_callocN(sizeof(Point3d)*64,"NURBS_Degree::Elevate ");
UV *= (obj -> Order(0) > obj -> Order(1)) ? obj -> Order(0) : obj -> Order(1);
- Coef = (float*)malloc(sizeof(float)*(UV));
+ Coef = (float*)MEM_callocN(sizeof(float)*(UV),"NURBS_Degree::Elevate ");
UV = (obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc) > (obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc) ? obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc : obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc;
- Qw = (Point3d*)malloc(sizeof(Point3d)*UV);
- Pts = (Point3d*)malloc(sizeof(Point3d)*UV);
- FnlPts = (Point3d*)malloc(sizeof(Point3d)*(obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc)*(obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc));
+ Qw = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate ");
+ Pts = (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Elevate ");
+ FnlPts = (Point3d*)MEM_callocN(sizeof(Point3d)*(obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc)*(obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc),"NURBS_Degree::Elevate ");
+ FnlKVU = (float*)MEM_callocN(sizeof(float)*(obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0)),"NURBS_Degree::Elevate ");
+ FnlKVV = (float*)MEM_callocN(sizeof(float)*(obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)),"NURBS_Degree::Elevate ");
+ Uh = (float*)MEM_callocN(sizeof(float)*((obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0)) > (obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)) ? obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0) : obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)),"NURBS_Degree::Elevate ");
- FnlKVU = (float*)malloc(sizeof(float)*(obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0)));
- FnlKVV = (float*)malloc(sizeof(float)*(obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)));
- Uh = (float*)malloc(sizeof(float)*((obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0)) > (obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)) ? obj -> Length(0)+(obj -> Length(0)-(obj -> Order(0)-1))*Uinc+Uinc+obj -> Order(0) : obj -> Length(1)+(obj -> Length(1)-(obj -> Order(1)-1))*Vinc+Vinc+obj -> Order(1)));
-
for(UV = 0; UV < 2; UV++) {
- Inc = UV ? Vinc : Uinc;
+ Inc = UV ? Uinc : Vinc;
if(Inc) {
Npts = obj -> Length(UV);
@@ -319,17 +318,17 @@
}
// Deallocate Memory
- free(FnlPts);
- free(Pts);
- free(Qw);
- free(FnlKVU);
- free(FnlKVV);
- free(bpts);
- free(ebpts);
- free(Nextbpts);
- free(Coefb);
- free(Uh);
- free(Coef);
+ MEM_freeN(FnlPts);
+ MEM_freeN(Pts);
+ MEM_freeN(Qw);
+ MEM_freeN(FnlKVU);
+ MEM_freeN(FnlKVV);
+ MEM_freeN(bpts);
+ MEM_freeN(ebpts);
+ MEM_freeN(Nextbpts);
+ MEM_freeN(Coefb);
+ MEM_freeN(Uh);
+ MEM_freeN(Coef);
}
@@ -437,20 +436,20 @@
// Memory Allocations
UV= (obj -> Length(0) > obj -> Length(1) ? obj -> Length(0) : obj -> Length(1));
- Pts= (Point3d*)malloc(sizeof(Point3d)*UV);
- Temp= (Point3d*)malloc(sizeof(Point3d)*UV);
+ Pts= (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Reduce ");
+ Temp= (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Reduce ");
UV= obj -> Length(0) + obj -> Order(0) > obj -> Length(1) + obj -> Order(1) ? obj -> Length(0) + obj -> Order(0) : obj -> Length(1) + obj -> Order(1);
- error= (float*)malloc(sizeof(float)*UV);
- Uh= (float*)malloc(sizeof(float)*UV);
- KnotVector= (float*)malloc(sizeof(float)*UV);
+ error= (float*)MEM_callocN(sizeof(float)*UV,"NURBS_Degree::Reduce ");
+ Uh= (float*)MEM_callocN(sizeof(float)*UV,"NURBS_Degree::Reduce ");
+ KnotVector= (float*)MEM_callocN(sizeof(float)*UV,"NURBS_Degree::Reduce ");
UV= (obj -> Order(0) > obj -> Order(1) ? obj -> Order(0) : obj -> Order(1));
- bpts= (Point3d*)malloc(sizeof(Point3d)*UV);
- rbpts= (Point3d*)malloc(sizeof(Point3d)*UV);
- Nextbpts= (Point3d*)malloc(sizeof(Point3d)*UV);
- alphas= (float*)malloc(sizeof(float)*UV);
- FnlPts= (Point3d*)malloc(sizeof(Point3d)*(obj -> Length(0) * obj -> Length(1)));
- FnlKVU= (float*)malloc(sizeof(float)*(obj -> Length(0) + obj -> Order(0)));
- FnlKVV= (float*)malloc(sizeof(float)*(obj -> Length(1) + obj -> Order(1)));
+ bpts= (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Reduce ");
+ rbpts= (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Reduce ");
+ Nextbpts= (Point3d*)MEM_callocN(sizeof(Point3d)*UV,"NURBS_Degree::Reduce ");
+ alphas= (float*)MEM_callocN(sizeof(float)*UV,"NURBS_Degree::Reduce ");
+ FnlPts= (Point3d*)MEM_callocN(sizeof(Point3d)*(obj -> Length(0) * obj -> Length(1)),"NURBS_Degree::Reduce ");
+ FnlKVU= (float*)MEM_callocN(sizeof(float)*(obj -> Length(0) + obj -> Order(0)),"NURBS_Degree::Reduce ");
+ FnlKVV= (float*)MEM_callocN(sizeof(float)*(obj -> Length(1) + obj -> Order(1)),"NURBS_Degree::Reduce ");
for(UV= 0; UV < 2; UV++) {
@@ -734,16 +733,16 @@
// Free Memory
- free(Pts);
- free(Temp);
- free(Uh);
- free(bpts);
- free(rbpts);
- free(alphas);
- free(Nextbpts);
- free(FnlPts);
- free(FnlKVU);
- free(FnlKVV);
- free(KnotVector);
- free(error);
+ MEM_freeN(Pts);
+ MEM_freeN(Temp);
+ MEM_freeN(Uh);
+ MEM_freeN(bpts);
+ MEM_freeN(rbpts);
+ MEM_freeN(alphas);
+ MEM_freeN(Nextbpts);
+ MEM_freeN(FnlPts);
+ MEM_freeN(FnlKVU);
+ MEM_freeN(FnlKVV);
+ MEM_freeN(KnotVector);
+ MEM_freeN(error);
}
Modified: branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp
===================================================================
--- branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp 2007-11-19 20:13:14 UTC (rev 12628)
+++ branches/nurbs/blender/intern/nurbana/intern/NURBS_Generate.cpp 2007-11-19 21:12:30 UTC (rev 12629)
@@ -2,8 +2,8 @@
//NurbData NURBS_Generate::nurbData;
void NURBS_Generate::Surface(Object_NURBS *obj, nbReal* buffer, int dim) {
- int Vnpts;
-
+ int Vnpts;
+
Vnpts = obj -> Length(1);
// Blender seems to use a different tess for curves and surfaces, numCPu*resU vs resU*resV
@@ -11,33 +11,33 @@
Surface(obj, obj -> Tess(0) * obj-> Length(0) , obj -> Tess(1) * Vnpts , dim, buffer, obj -> Sum(), 0, 0, 1);
else
Surface(obj, obj -> Tess(0), obj -> Tess(1) , dim, buffer, obj -> Sum(), 0, 0, 1);
-
+
//IsoLines(obj);
}
void NURBS_Generate::IsoLines(Object_NURBS *obj, nbReal* buffer) {
int Change;
Change= obj->Change(1);
-// Surface(obj, obj -> IPCResolution(), obj -> IPCDensity(), obj -> IPCPts(), obj -> SumIPC(0), 0, 1, 0);
-// if(!Change) obj->Change(1,0);
-// Surface(obj,obj->IPCDensity(),obj->IPCResolution(),obj->IPCPts(),obj->SumIPC(1),obj->IPCResolution()*obj->IPCDensity(),1,0);
-//
+ // Surface(obj, obj -> IPCResolution(), obj -> IPCDensity(), obj -> IPCPts(), obj -> SumIPC(0), 0, 1, 0);
+ // if(!Change) obj->Change(1,0);
+ // Surface(obj,obj->IPCDensity(),obj->IPCResolution(),obj->IPCPts(),obj->SumIPC(1),obj->IPCResolution()*obj->IPCDensity(),1,0);
+ //
Surface(obj, obj -> IPCDensity(), obj -> IPCResolution(), 3, buffer, obj -> SumIPC(0), 0, 1, 0);
if(!Change) obj->Change(1,0);
Surface(obj,obj->IPCResolution(),obj->IPCDensity(), 3, buffer, obj->SumIPC(1),obj->IPCResolution()*obj->IPCDensity(),1,0);
-
-
+
+
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list