|
@ -7,11 +7,165 @@ |
|
|
#include "gauss_map.h" |
|
|
#include "gauss_map.h" |
|
|
#include "bvh.h" |
|
|
#include "bvh.h" |
|
|
#include "utils.h" |
|
|
#include "utils.h" |
|
|
|
|
|
#include "unordered_set" |
|
|
|
|
|
#include "unordered_map" |
|
|
|
|
|
|
|
|
|
|
|
array2<glm::vec3> getPtsFromStr(QString srfData); |
|
|
|
|
|
void printCtrPtsAsQuadruples(const RationalSurface<float> &s); |
|
|
|
|
|
void printCtrPtsAsQuadruples(const Surface<double> &s); |
|
|
|
|
|
|
|
|
|
|
|
void sampleTimeTest(const RationalSurface<float> &s_, int sampleLevel) { |
|
|
|
|
|
// 由于ParaSolid那边曲面参数为double类型,这里也要保证是double类型(控制变量)
|
|
|
|
|
|
RationalSurface<double> s; |
|
|
|
|
|
vector<double> knots_u(s_.knots_u.size()); |
|
|
|
|
|
vector<double> knots_v(s_.knots_v.size()); |
|
|
|
|
|
array2<double> weights(s_.weights.rows(), s_.weights.cols()); |
|
|
|
|
|
array2<glm::vec<3, double>> control_points(s_.control_points.rows(), s_.control_points.cols()); |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < s_.knots_u.size(); i++) knots_u[i] = (double)s_.knots_u[i]; |
|
|
|
|
|
for(int i = 0; i < s_.knots_v.size(); i++) knots_v[i] = (double)s_.knots_v[i]; |
|
|
|
|
|
for(int i = 0; i < s_.weights.rows(); i++) { |
|
|
|
|
|
for(int j = 0; j < s_.weights.cols(); j++) { |
|
|
|
|
|
weights(i, j) = (double)s_.weights(i, j); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
for(int i = 0; i < s_.control_points.rows(); i++) { |
|
|
|
|
|
for(int j = 0; j < s_.control_points.cols(); j++) { |
|
|
|
|
|
control_points(i, j).x = (double)s_.control_points(i, j).x; |
|
|
|
|
|
control_points(i, j).y = (double)s_.control_points(i, j).y; |
|
|
|
|
|
control_points(i, j).z = (double)s_.control_points(i, j).z; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
s.knots_u = knots_u; |
|
|
|
|
|
s.knots_v = knots_v; |
|
|
|
|
|
s.weights = weights; |
|
|
|
|
|
s.control_points = control_points; |
|
|
|
|
|
s.degree_u = s_.degree_u; |
|
|
|
|
|
s.degree_v = s_.degree_v; |
|
|
|
|
|
auto sampleCnt = int(pow(2, sampleLevel - 1) + 1); |
|
|
|
|
|
auto s_first_u = *(s.knots_u.begin()); |
|
|
|
|
|
auto s_first_v = *(s.knots_v.begin()); |
|
|
|
|
|
auto s_step_u = (*(s.knots_u.end() - 1) - s_first_u) / double (sampleCnt - 1); |
|
|
|
|
|
auto s_step_v = (*(s.knots_v.end() - 1) - s_first_v) / double (sampleCnt - 1); |
|
|
|
|
|
// 为了分别测试赋值和求梯度的时间,这里把它们分开写了
|
|
|
|
|
|
|
|
|
|
|
|
auto startMomEval = std::chrono::steady_clock::now(); |
|
|
|
|
|
for (int i = 0; i < sampleCnt; i++) { |
|
|
|
|
|
auto u = s_first_u + s_step_u * float(i); |
|
|
|
|
|
for (int j = 0; j < sampleCnt; j++) { |
|
|
|
|
|
auto v = s_first_v + s_step_v * float(j); |
|
|
|
|
|
auto eval = tinynurbs::surfacePoint(s, u, v); |
|
|
|
|
|
// printf("(%d, %d) --> (%g, %g, %g)\n", i, j, eval.x, eval.y, eval.z);
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
auto endMomEval = std::chrono::steady_clock::now(); |
|
|
|
|
|
printf("time cost of evaluation: %lf ms\n", std::chrono::duration<double, std::milli>(endMomEval - startMomEval).count()); |
|
|
|
|
|
|
|
|
|
|
|
auto startMomDer = std::chrono::steady_clock::now(); |
|
|
|
|
|
for (int i = 0; i < sampleCnt; i++) { |
|
|
|
|
|
auto u = s_first_u + s_step_u * float(i); |
|
|
|
|
|
for (int j = 0; j < sampleCnt; j++) { |
|
|
|
|
|
auto v = s_first_v + s_step_v * float(j); |
|
|
|
|
|
auto der = tinynurbs::surfaceDerivatives(s, 1, u, v); |
|
|
|
|
|
// if(der(0, 0) == res.evaluation[i][j]) cout<<"amazing"<<endl;
|
|
|
|
|
|
// else cout<<"what??? ("<<res.evaluation[i][j].x<<" "<<res.evaluation[i][j].y<<" "<<res.evaluation[i][j].z<<") | ("<<der(0, 0).x<<" "<<der(0, 0).y<<" "<<der(0, 0).z<<")"<<endl;
|
|
|
|
|
|
// res.tangent_u[i][j] = der(1, 0);
|
|
|
|
|
|
// res.tangent_v[i][j] = der(0, 1);
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
auto endMomDer = std::chrono::steady_clock::now(); |
|
|
|
|
|
printf("time cost of derivatives: %lf ms\n", std::chrono::duration<double, std::milli>(endMomDer - startMomDer).count()); |
|
|
|
|
|
|
|
|
|
|
|
auto startMomScdDer = std::chrono::steady_clock::now(); |
|
|
|
|
|
for (int i = 0; i < sampleCnt; i++) { |
|
|
|
|
|
auto u = s_first_u + s_step_u * float(i); |
|
|
|
|
|
for (int j = 0; j < sampleCnt; j++) { |
|
|
|
|
|
auto v = s_first_v + s_step_v * float(j); |
|
|
|
|
|
auto der = tinynurbs::surfaceDerivatives(s, 2, u, v); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
auto endMomScdDer = std::chrono::steady_clock::now(); |
|
|
|
|
|
printf("time cost of second derivatives: %lf ms\n", std::chrono::duration<double, std::milli>(endMomScdDer - startMomScdDer).count()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void sampleTimeTestNonRational(const RationalSurface<float> &s_, int sampleLevel) { |
|
|
|
|
|
// 由于ParaSolid那边曲面参数为double类型,这里也要保证是double类型(控制变量)
|
|
|
|
|
|
Surface<double> s; |
|
|
|
|
|
vector<double> knots_u(s_.knots_u.size()); |
|
|
|
|
|
vector<double> knots_v(s_.knots_v.size()); |
|
|
|
|
|
array2<glm::vec<3, double>> control_points(s_.control_points.rows(), s_.control_points.cols()); |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < s_.knots_u.size(); i++) knots_u[i] = (double)s_.knots_u[i]; |
|
|
|
|
|
for(int i = 0; i < s_.knots_v.size(); i++) knots_v[i] = (double)s_.knots_v[i]; |
|
|
|
|
|
for(int i = 0; i < s_.control_points.rows(); i++) { |
|
|
|
|
|
for(int j = 0; j < s_.control_points.cols(); j++) { |
|
|
|
|
|
control_points(i, j).x = (double)s_.control_points(i, j).x; |
|
|
|
|
|
control_points(i, j).y = (double)s_.control_points(i, j).y; |
|
|
|
|
|
control_points(i, j).z = (double)s_.control_points(i, j).z; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
s.knots_u = knots_u; |
|
|
|
|
|
s.knots_v = knots_v; |
|
|
|
|
|
s.control_points = control_points; |
|
|
|
|
|
s.degree_u = s_.degree_u; |
|
|
|
|
|
s.degree_v = s_.degree_v; |
|
|
|
|
|
auto sampleCnt = int(pow(2, sampleLevel - 1) + 1); |
|
|
|
|
|
auto s_first_u = *(s.knots_u.begin()); |
|
|
|
|
|
auto s_first_v = *(s.knots_v.begin()); |
|
|
|
|
|
auto s_step_u = (*(s.knots_u.end() - 1) - s_first_u) / double (sampleCnt - 1); |
|
|
|
|
|
auto s_step_v = (*(s.knots_v.end() - 1) - s_first_v) / double (sampleCnt - 1); |
|
|
|
|
|
// 为了分别测试赋值和求梯度的时间,这里把它们分开写了
|
|
|
|
|
|
|
|
|
|
|
|
printCtrPtsAsQuadruples(s); |
|
|
|
|
|
|
|
|
|
|
|
auto startMomEval = std::chrono::steady_clock::now(); |
|
|
|
|
|
for (int i = 0; i < sampleCnt; i++) { |
|
|
|
|
|
auto u = s_first_u + s_step_u * float(i); |
|
|
|
|
|
for (int j = 0; j < sampleCnt; j++) { |
|
|
|
|
|
auto v = s_first_v + s_step_v * float(j); |
|
|
|
|
|
auto eval = tinynurbs::surfacePoint(s, u, v); |
|
|
|
|
|
// res.evaluation[i][j] = tinynurbs::surfacePoint(s, u, v);
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
auto endMomEval = std::chrono::steady_clock::now(); |
|
|
|
|
|
printf("time cost of evaluation: %lf ms\n", std::chrono::duration<double, std::milli>(endMomEval - startMomEval).count()); |
|
|
|
|
|
|
|
|
|
|
|
auto startMomDer = std::chrono::steady_clock::now(); |
|
|
|
|
|
for (int i = 0; i < sampleCnt; i++) { |
|
|
|
|
|
auto u = s_first_u + s_step_u * float(i); |
|
|
|
|
|
for (int j = 0; j < sampleCnt; j++) { |
|
|
|
|
|
auto v = s_first_v + s_step_v * float(j); |
|
|
|
|
|
auto der = tinynurbs::surfaceDerivatives(s, 1, u, v); |
|
|
|
|
|
// if(der(0, 0) == res.evaluation[i][j]) cout<<"amazing"<<endl;
|
|
|
|
|
|
// else cout<<"what??? ("<<res.evaluation[i][j].x<<" "<<res.evaluation[i][j].y<<" "<<res.evaluation[i][j].z<<") | ("<<der(0, 0).x<<" "<<der(0, 0).y<<" "<<der(0, 0).z<<")"<<endl;
|
|
|
|
|
|
// res.tangent_u[i][j] = der(1, 0);
|
|
|
|
|
|
// res.tangent_v[i][j] = der(0, 1);
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
auto endMomDer = std::chrono::steady_clock::now(); |
|
|
|
|
|
printf("time cost of derivatives: %lf ms\n", std::chrono::duration<double, std::milli>(endMomDer - startMomDer).count()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto startMomScdDer = std::chrono::steady_clock::now(); |
|
|
|
|
|
for (int i = 0; i < sampleCnt; i++) { |
|
|
|
|
|
auto u = s_first_u + s_step_u * float(i); |
|
|
|
|
|
for (int j = 0; j < sampleCnt; j++) { |
|
|
|
|
|
auto v = s_first_v + s_step_v * float(j); |
|
|
|
|
|
auto der = tinynurbs::surfaceDerivatives(s, 2, u, v); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
auto endMomScdDer = std::chrono::steady_clock::now(); |
|
|
|
|
|
printf("time cost of second derivatives: %lf ms\n", std::chrono::duration<double, std::milli>(endMomScdDer - startMomScdDer).count()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
SrfMesh getMesh(const RationalSurface<float> &s, int sampleLevel) { |
|
|
SrfMesh getMesh(const RationalSurface<float> &s, int sampleLevel) { |
|
|
SrfMesh res; |
|
|
SrfMesh res; |
|
|
res.sampleLevel = sampleLevel; |
|
|
res.sampleLevel = sampleLevel; |
|
|
res.sampleCntOnSingleDir = int(pow(2, sampleLevel - 1) + 1); |
|
|
auto sampleCnt = res.sampleCntOnSingleDir = int(pow(2, sampleLevel - 1) + 1); |
|
|
res.evaluation = vector<vector<glm::vec3>>(res.sampleCntOnSingleDir, vector<glm::vec3>(res.sampleCntOnSingleDir)); |
|
|
res.evaluation = vector<vector<glm::vec3>>(res.sampleCntOnSingleDir, vector<glm::vec3>(res.sampleCntOnSingleDir)); |
|
|
res.tangent_u = vector<vector<glm::vec3>>(res.sampleCntOnSingleDir, vector<glm::vec3>(res.sampleCntOnSingleDir)); |
|
|
res.tangent_u = vector<vector<glm::vec3>>(res.sampleCntOnSingleDir, vector<glm::vec3>(res.sampleCntOnSingleDir)); |
|
|
res.tangent_v = vector<vector<glm::vec3>>(res.sampleCntOnSingleDir, vector<glm::vec3>(res.sampleCntOnSingleDir)); |
|
|
res.tangent_v = vector<vector<glm::vec3>>(res.sampleCntOnSingleDir, vector<glm::vec3>(res.sampleCntOnSingleDir)); |
|
@ -22,26 +176,62 @@ SrfMesh getMesh(const RationalSurface<float> &s, int sampleLevel) { |
|
|
auto s_step_u = (*(s.knots_u.end() - 1) - s_first_u) / float(res.sampleCntOnSingleDir - 1); |
|
|
auto s_step_u = (*(s.knots_u.end() - 1) - s_first_u) / float(res.sampleCntOnSingleDir - 1); |
|
|
auto s_step_v = (*(s.knots_v.end() - 1) - s_first_v) / float(res.sampleCntOnSingleDir - 1); |
|
|
auto s_step_v = (*(s.knots_v.end() - 1) - s_first_v) / float(res.sampleCntOnSingleDir - 1); |
|
|
|
|
|
|
|
|
for (int i = 0; i < res.sampleCntOnSingleDir; i++) { |
|
|
// evaluation correction test
|
|
|
|
|
|
auto u = 0.35f; |
|
|
|
|
|
auto v = 0.35f; |
|
|
|
|
|
auto pt = tinynurbs::surfacePoint(s, u, v); |
|
|
|
|
|
printf("pt on u = %g, v = %g is (%f, %f, %f)\n", u, v, pt.x, pt.y, pt.z); |
|
|
|
|
|
auto der = tinynurbs::surfaceDerivatives(s, 1, u, v); |
|
|
|
|
|
auto du = der(1, 0); |
|
|
|
|
|
auto dv = der(0, 1); |
|
|
|
|
|
printf("derivatives of u when u = %g, v = %g is (%f, %f, %f)\n", u, v, du.x, du.y, du.z); |
|
|
|
|
|
printf("derivatives of v when u = %g, v = %g is (%f, %f, %f)\n", u, v, dv.x, dv.y, dv.z); |
|
|
|
|
|
// end of correction test
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < sampleCnt; i++) { |
|
|
auto u = s_first_u + s_step_u * float(i); |
|
|
auto u = s_first_u + s_step_u * float(i); |
|
|
for (int j = 0; j < res.sampleCntOnSingleDir; j++) { |
|
|
for (int j = 0; j < sampleCnt; j++) { |
|
|
auto v = s_first_v + s_step_v * float(j); |
|
|
auto v = s_first_v + s_step_v * float(j); |
|
|
res.evaluation[i][j] = tinynurbs::surfacePoint(s, u, v); |
|
|
res.evaluation[i][j] = tinynurbs::surfacePoint(s, u, v); |
|
|
auto der = tinynurbs::surfaceDerivatives(s, 1, u, v); |
|
|
auto der = tinynurbs::surfaceDerivatives(s, 1, u, v); |
|
|
|
|
|
// if(der(0, 0) == res.evaluation[i][j]) cout<<"amazing"<<endl;
|
|
|
|
|
|
// else cout<<"what??? ("<<res.evaluation[i][j].x<<" "<<res.evaluation[i][j].y<<" "<<res.evaluation[i][j].z<<") | ("<<der(0, 0).x<<" "<<der(0, 0).y<<" "<<der(0, 0).z<<")"<<endl;
|
|
|
res.tangent_u[i][j] = der(1, 0); |
|
|
res.tangent_u[i][j] = der(1, 0); |
|
|
res.tangent_v[i][j] = der(0, 1); |
|
|
res.tangent_v[i][j] = der(0, 1); |
|
|
res.normal[i][j] = glm::normalize(glm::cross(res.tangent_u[i][j], res.tangent_v[i][j])); |
|
|
res.normal[i][j] = glm::normalize(glm::cross(res.tangent_u[i][j], res.tangent_v[i][j])); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return res; |
|
|
return res; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
array2<glm::vec3> getPtsFromStr(QString srfData); |
|
|
int dirs[4][2] = {{-1, 0}, |
|
|
|
|
|
{0, 1}, |
|
|
|
|
|
{1, 0}, |
|
|
|
|
|
{0, -1}}; |
|
|
|
|
|
|
|
|
|
|
|
void dfs(const map<pair<int, int>, set<pair<int, int>>>& pairMap, |
|
|
|
|
|
// unordered_map<pair<int, int>, char> &book,
|
|
|
|
|
|
set<pair<int, int>>& book, |
|
|
|
|
|
// vector<vector<pair<pair<int, int>, pair<int, int>>>> &boxGroups,
|
|
|
|
|
|
vector<vector<pair<int, int>>> &boxGroups, |
|
|
|
|
|
int x, int y, int iOfGroup) { |
|
|
|
|
|
// book[{x, y}] = 1;
|
|
|
|
|
|
// book.insert(pair<pair<int, int>, char>(pair<int, int>(x, y), 1));
|
|
|
|
|
|
book.insert({x,y}); |
|
|
|
|
|
boxGroups[iOfGroup].emplace_back(pair<int, int>(x, y)); |
|
|
|
|
|
for (auto dir: dirs) { |
|
|
|
|
|
auto nx = x + dir[0], ny = y + dir[1]; |
|
|
|
|
|
if (book.find({nx, ny}) != book.end() || pairMap.find({nx, ny}) == pairMap.end())continue; |
|
|
|
|
|
dfs(pairMap, book, boxGroups, nx, ny, iOfGroup); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int main() { |
|
|
int main() { |
|
|
RationalSurface<float> s; |
|
|
RationalSurface<float> s; |
|
|
RationalSurface<float> f; |
|
|
RationalSurface<float> f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int level = 6; |
|
|
int level = 6; |
|
|
printf("level: %d, sample cnt: %d * %d\n", level, int(pow(2, level - 1)), int(pow(2, level - 1))); |
|
|
printf("level: %d, sample cnt: %d * %d\n", level, int(pow(2, level - 1)), int(pow(2, level - 1))); |
|
|
|
|
|
|
|
@ -101,6 +291,8 @@ int main() { |
|
|
|
|
|
|
|
|
fin.close(); |
|
|
fin.close(); |
|
|
|
|
|
|
|
|
|
|
|
printCtrPtsAsQuadruples(f); |
|
|
|
|
|
|
|
|
// ====================== 测试 =======================
|
|
|
// ====================== 测试 =======================
|
|
|
vector<vector<glm::vec3>> s_evaluation; |
|
|
vector<vector<glm::vec3>> s_evaluation; |
|
|
vector<vector<glm::vec3>> f_evaluation; |
|
|
vector<vector<glm::vec3>> f_evaluation; |
|
@ -112,6 +304,9 @@ int main() { |
|
|
const vector<vector<glm::vec3>> s_normal; |
|
|
const vector<vector<glm::vec3>> s_normal; |
|
|
const vector<vector<glm::vec3>> f_normal; |
|
|
const vector<vector<glm::vec3>> f_normal; |
|
|
|
|
|
|
|
|
|
|
|
// sampleTimeTestNonRational(s, level);
|
|
|
|
|
|
sampleTimeTest(s, level); |
|
|
|
|
|
|
|
|
auto mesh1 = getMesh(s, level); |
|
|
auto mesh1 = getMesh(s, level); |
|
|
auto mesh2 = getMesh(f, level); |
|
|
auto mesh2 = getMesh(f, level); |
|
|
|
|
|
|
|
@ -121,6 +316,31 @@ int main() { |
|
|
bvh2.build(); |
|
|
bvh2.build(); |
|
|
auto intersectBoxPairs = getOverlapLeafNodes(bvh1, bvh2); // [{{u1, v1}, {u2, v2}}]
|
|
|
auto intersectBoxPairs = getOverlapLeafNodes(bvh1, bvh2); // [{{u1, v1}, {u2, v2}}]
|
|
|
printf("box pairs size: %lld\n", intersectBoxPairs.size()); |
|
|
printf("box pairs size: %lld\n", intersectBoxPairs.size()); |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 测试对bvh结果用dfs |
|
|
|
|
|
*/ |
|
|
|
|
|
// double timeClassify = utils::get_time();
|
|
|
|
|
|
// map<pair<int, int>, set<pair<int, int>>> pairMap;
|
|
|
|
|
|
// for (const auto &boxPair: intersectBoxPairs) {
|
|
|
|
|
|
// pairMap[boxPair.first].insert(boxPair.second);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//// vector<vector<pair<pair<int, int>, pair<int, int>>>> groups;
|
|
|
|
|
|
// vector<vector<pair<int, int>>> groups;
|
|
|
|
|
|
//// unordered_map<pair<int, int>, char> book;
|
|
|
|
|
|
// set<pair<int, int>>book;
|
|
|
|
|
|
// int groupNum = 0;
|
|
|
|
|
|
// for(auto boxPair: intersectBoxPairs) {
|
|
|
|
|
|
// if(book.find(boxPair.first) != book.end())continue;
|
|
|
|
|
|
// groups.emplace_back();
|
|
|
|
|
|
// dfs(pairMap, book, groups, boxPair.first.first, boxPair.first.second, groupNum++);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// timeClassify = utils::get_time() - timeClassify;
|
|
|
|
|
|
// printf("time cost to group boxes from BVH: %lf\n", timeClassify);
|
|
|
|
|
|
/**
|
|
|
|
|
|
* end of test |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
double time_cost = utils::get_time(); |
|
|
double time_cost = utils::get_time(); |
|
|
SingularityJudger singularityJudger(s, f, mesh1, mesh2); |
|
|
SingularityJudger singularityJudger(s, f, mesh1, mesh2); |
|
|
|
|
|
|
|
@ -177,4 +397,27 @@ array2<glm::vec3> getPtsFromStr(QString srfData) { |
|
|
} |
|
|
} |
|
|
array2<glm::vec3> res = {(size_t) dimU, (size_t) dimV, points}; |
|
|
array2<glm::vec3> res = {(size_t) dimU, (size_t) dimV, points}; |
|
|
return res; |
|
|
return res; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void printCtrPtsAsQuadruples(const RationalSurface<float> &s) { |
|
|
|
|
|
cout<<endl; |
|
|
|
|
|
for(int i = 0; i < s.control_points.rows(); i++) { |
|
|
|
|
|
for(int j = 0; j < s.control_points.cols(); j++) { |
|
|
|
|
|
auto pt = s.control_points(i, j); |
|
|
|
|
|
auto w = s.weights(i, j); |
|
|
|
|
|
cout<<pt.x * w<<", "<<pt.y * w<<", "<<pt.z * w<<", "<<s.weights(i, j)<<", "<<endl; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
cout<<s.control_points.rows() * s.control_points.cols() * 4 << endl; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void printCtrPtsAsQuadruples(const Surface<double> &s) { |
|
|
|
|
|
cout<<endl; |
|
|
|
|
|
for(int i = 0; i < s.control_points.rows(); i++) { |
|
|
|
|
|
for(int j = 0; j < s.control_points.cols(); j++) { |
|
|
|
|
|
auto pt = s.control_points(i, j); |
|
|
|
|
|
cout<<pt.x<<", "<<pt.y<<", "<<pt.z<<", "<<endl; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
cout<<s.control_points.rows() * s.control_points.cols() * 4 << endl; |
|
|
} |
|
|
} |