Britton Ward 0 Report post Posted May 23, 2014 Hi, I've written a simple export routine for another Nurbs surface modeler and the export works well. I'm trying to write an import feature to read the same type of file and produce a Nurbs surface. Portion of the code here. I read the knot vector without any trouble [from a single, comma separated line]. When I try to .setUKnotvector() of my new surface and pass the uKnots list I get compilation errors. I have tried all sorts of casting options and other options but I cannot seem to get uKnots passed into FSImport.setUKnotvector(uKnots) Any advice would be appreciated. Thanks,Britt string line(file.readLine())ObjectList uKnots(line.splitByRegExp("[, ]")).castTo(FString).todouble()int nukts(uKnots.getCount()) //FSimport.setUknotvector.addValues(data.castTo(FSeries))//Fseries uKnots.addvalues(data)//FSImport.setUKnotvector.addValues(uKnots.castTo(FSeries)) string line(file.readLine())objectList vKnots(line.splitByRegExp("[, ]")).castTo(FString).todouble()int nvkts(vKnots.getCount()) nurbssurface FSImport().setName(surfname)FSImport.setUdegree(uDeg)FSImport.setVdegree(vDeg)FSImport.setUknotvector(uKnots())FSImport.setVknotvector(vKnots) Share this post Link to post Share on other sites
Stefan Wunderlich 6 Report post Posted May 26, 2014 Hi Britt, I think we really have to clean our command interface at some places, since I had to figure out myself how to do this ;) This would be a possibility: // ------------------------------------------------------string line(file.readLine())objectList uKnots(line.splitByRegExp("[, ]"))objectList vKnots(line.splitByRegExp("[, ]")) // we need a fdoubleseries as typefdoubleseries uk() // foreach walks over each entry and performs castto() implicitlyforeach(double k : uKnots) uk.push_back(k)endfor fdoubleseries vk()foreach(double k : vKnots) vk.push_back(k)endfor nurbssurface FSImport().setName(surfname)FSImport.setUdegree(uDeg)FSImport.setVdegree(vDeg)FSImport.setUknotvector(uk)FSImport.setVknotvector(vk)// ------------------------------------------------------ Please be aware that weights are set by objectlist (which is not really consistent). I hope that helps. Cheers,Stefan Share this post Link to post Share on other sites
Britton Ward 0 Report post Posted May 27, 2014 Stefan, Thanks for your help. I think I would have stumbled around for days without finding this! I tried to extend what you showed to add the control points and weights but am hitting another road block. I am reading a list of control points in the following format. Each point on a line. X, Y, Z of vertex and then the weight. I was planning on reading the line into a Fdoubleseries as before and then putting the first 3 elements into the control point array and the last into the weights object list.. but again am missing something.... Thanks for any guidance you might have! Britt X,Y,Z,WT -9.676823, 0.000000, -0.179737, 1.000000-9.676817, 0.119120, -0.179743, 1.000000-9.676816, 0.396021, -0.179943, 1.000000-9.676822, 0.765867, -0.217755, 1.000000-9.676806, 1.092176, -0.297093, 1.000000-9.676817, 1.366311, -0.423463, 1.000000-9.676838, 1.496214, -0.644759, 1.000000-9.676845, 1.620421, -0.856858, 1.000000-9.676815, 1.789719, -1.145828, 1.000000-9.676839, 1.892176, -1.321044, 1.000000 //Read Nodesunsigned idu(0) loop(nU) unsigned idv(0) loop(nv)string line(file.readLine())objectList data(line.splitByRegExp("[, ]")) //.castTo(FString).todouble() fdoubleseries dpt() foreach(double k : data)dpt.push_back(k)endforfVector3 vec() // echo(dpt.at(0).castto(FString)) // vec.setVector([dpt.at(0),dpt.at(1),dpt.at(2)]) // FSImport.SetPointArray.add() idV+=1endloop idU+=1endloop Share this post Link to post Share on other sites
Stefan Wunderlich 6 Report post Posted May 27, 2014 Hi Britt, I would probably do something like this (I did not test it, so I hope it is correct): // we need to now this from somewhereunsigned nu(10)unsigned nv(10)ffile file("...")file.openRead() // we need to now this from somewhere, maybe read it from file?unsigned nu(10)unsigned nv(10)objectlist points()objectlist weights()loop(nu) // we need to build 2d arrays -> objectlist of objectlists objectlist rowPoints() objectlist rowWeights() points.add(rowPoints) weights.add(rowWeights) loop(nv) string line(file.readLine()) objectList data(line.splitByRegExp("[, ]")) FVector3 vec() vec.set([#data.at(0).castTo(double), #data.at(1).castTo(double), #data.at(2).castTo(double)]) // the # detaches the value from the expression double weight(data.at(3).castTo(double)) // # not needed here since double is always detached rowPoints.add(vec) rowWeights.add(weight) endloopendloopnurbssurface surf()surf.setPointArray(points)surf.setWeights(weights) Hope that brings you on the road again. Just ask if you need any further guidance. Cheers,Stefan Share this post Link to post Share on other sites