15 #include "isoPlacer.h"
16 #include "qtessSurface.h"
17 #include "subdivSegment.h"
18 #include "nurbsSurfaceResult.h"
28 get_scores(
int subdiv,
int across,
double ratio,
35 _cscore.reserve(_maxi);
36 _sscore.reserve(_maxi);
41 for (i = 0; i < _maxi; i++) {
42 _cscore.push_back(0.0);
43 _sscore.push_back(0.0);
47 for (a = 0; a <= across; a++) {
48 double v = (double)a / (
double)across;
59 for (i = -1; i < _maxi; i++) {
60 double u = (double)(i+1) / (double)(_maxi+1);
77 double vlength = length(v2);
81 _sscore[i] += vlength;
84 if (num_points >= 3) {
87 double d = v1.dot(v2);
89 _cscore[i] += acos(max(min(d, 1.0), -1.0));
97 _cint.reserve(_maxi + 1);
100 double ad = (double)(across+1);
101 _cint.push_back(0.0);
102 for (i = 0; i < _maxi; i++) {
103 net += _cscore[i]/ad + ratio * _sscore[i]/ad;
104 _cint.push_back(net);
118 double avg_curve = 0.0;
119 for (i = 0; i < _maxi; i++) {
120 avg_curve += _cscore[i];
122 avg_curve /= (double)_maxi;
128 BendPoints::iterator bi, bnext;
132 Segments::iterator si;
151 bi = bpoints.begin();
152 int min_separation = _maxi/count;
153 while (bi != bpoints.end()) {
157 if (bnext != bpoints.end() && (*bnext) - (*bi) < min_separation) {
159 if (_cscore[*bnext] > _cscore[*bi]) {
162 bpoints.erase(bnext);
171 while (count - 1 < (
int)bpoints.size()) {
172 bi = bpoints.begin();
173 BendPoints::iterator mi = bi;
174 for (++bi; bi != bpoints.end(); ++bi) {
175 if (_cscore[*bi] < _cscore[*mi]) {
183 bi = bpoints.begin();
185 for (bi = bpoints.begin(); bi != bpoints.end(); ++bi) {
191 int nr = count - segments.size();
200 double net_score = _cint[_maxi];
201 nassertv(net_score > 0.0);
203 for (si = segments.begin(); si != segments.end(); ++si) {
204 (*si)._num_cuts = (int)floor(nr * (*si).get_score() / net_score);
205 nassertv((*si)._num_cuts <= nr);
206 ns += (*si)._num_cuts;
212 si = min_element(segments.begin(), segments.end());
218 for (si = segments.begin(); si != segments.end(); ++si) {
223 iso_points.erase(iso_points.begin(), iso_points.end());
225 iso_points.push_back(0.0);
226 for (si = segments.begin(); si != segments.end(); ++si) {
228 for (ci = (*si)._cuts.begin(); ci != (*si)._cuts.end(); ++ci) {
229 iso_points.push_back((*ci+1) / (
double)(_maxi+1));
231 iso_points.push_back(((*si)._t+1) / (
double)(_maxi+1));
235 iso_points.back() = 1.0;
This is the base class for all three-component vectors and points.
The result of a NurbsSurfaceEvaluator.
bool eval_point(PN_stdfloat u, PN_stdfloat v, LVecBase3 &point)
Computes the point on the surface corresponding to the indicated value in parametric time...
bool almost_equal(const LVecBase3f &other, float threshold) const
Returns true if two vectors are memberwise equal within a specified tolerance.
Represents a single hypothetical subdivided segment, under consideration by the IsoPlacer.