Skip to content

Commit 29f0f2d

Browse files
committed
NURBS debugging code
Rebased onto trunk from ruevs/wip-intersection
1 parent 74a13ef commit 29f0f2d

File tree

8 files changed

+254
-16
lines changed

8 files changed

+254
-16
lines changed

src/dsc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,9 @@ class List {
264264

265265
public:
266266
int n = 0;
267+
uint32_t cc = 0;
267268

268-
bool IsEmpty() const { return n == 0; }
269+
bool IsEmpty() const { return 0 >= n; } // A negative number of list elements?!
269270

270271
void ReserveMore(int howMuch) {
271272
if(n + howMuch > elemsAllocated) {

src/platform/guiwin.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,16 @@ std::vector<std::string> InitGui(int argc, char **argv) {
17011701
SetLocale("en_US");
17021702
}
17031703

1704+
#ifndef NDEBUG
1705+
// create a debug console
1706+
if(AllocConsole()) {
1707+
(void)freopen("CONOUT$", "w", stdout/*stderr*/);
1708+
SetConsoleTitle(L"Debug Console");
1709+
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
1710+
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
1711+
}
1712+
#endif
1713+
17041714
return args;
17051715
}
17061716

src/polygon.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,14 @@ void SEdgeList::Clear() {
213213
l.Clear();
214214
}
215215

216-
void SEdgeList::AddEdge(Vector a, Vector b, int auxA, int auxB, int tag) {
216+
void SEdgeList::AddEdge(Vector a, Vector b, int auxA, int auxB, int tag, uint32_t cc) {
217217
SEdge e = {};
218218
e.tag = tag;
219219
e.a = a;
220220
e.b = b;
221221
e.auxA = auxA;
222222
e.auxB = auxB;
223+
e.cc = cc;
223224
l.Add(&e);
224225
}
225226

src/polygon.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum class EdgeKind : uint32_t {
3838
class SEdge {
3939
public:
4040
int tag;
41+
uint32_t cc;
4142
int auxA, auxB;
4243
Vector a, b;
4344

@@ -50,7 +51,7 @@ class SEdgeList {
5051
List<SEdge> l;
5152

5253
void Clear();
53-
void AddEdge(Vector a, Vector b, int auxA=0, int auxB=0, int tag=0);
54+
void AddEdge(Vector a, Vector b, int auxA=0, int auxB=0, int tag=0, uint32_t cc=0);
5455
bool AssemblePolygon(SPolygon *dest, SEdge *errorAt, bool keepDir=false) const;
5556
bool AssembleContour(Vector first, Vector last, SContour *dest,
5657
SEdge *errorAt, bool keepDir, int start) const;

src/render/rendergl1.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,28 @@ void OpenGl1Renderer::DrawLine(const Vector &a, const Vector &b, hStroke hcs) {
476476

477477
void OpenGl1Renderer::DrawEdges(const SEdgeList &el, hStroke hcs) {
478478
double phase = 0.0;
479+
unsigned n = 0;
479480
for(const SEdge *e = el.l.First(); e; e = el.l.NextAfter(e)) {
480481
DoStippledLine(e->a, e->b, hcs, phase);
481482
phase += e->a.Minus(e->b).Magnitude();
483+
484+
/*debug*/
485+
if(0 != e->cc) {
486+
std::shared_ptr<SolveSpace::ViewportCanvas> canvas = SS.GW.canvas;
487+
488+
const Camera &camera = canvas->GetCamera();
489+
490+
Canvas::Stroke strokeError = Style::Stroke(Style::DRAW_ERROR);
491+
strokeError.layer = Canvas::Layer::FRONT;
492+
strokeError.width = 1.0f;
493+
Canvas::hStroke hcsError = canvas->GetStroke(strokeError);
494+
495+
double textHeight = Style::DefaultTextHeight()*8 / camera.scale;
496+
497+
DrawVectorText(ssprintf(" %03u-%lu-%i-%i", n, e->cc, e->auxA, e->auxB ), textHeight + textHeight*n/1000, e->a,
498+
camera.projRight, camera.projUp, hcsError);
499+
++n;
500+
}
482501
}
483502
}
484503

0 commit comments

Comments
 (0)