CFx SDK Documentation  2022 SP0
FMDebugDraw.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2015, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2015 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #if !defined(DEBUG_DRAW_INCLUDED)
25 #define DEBUG_DRAW_INCLUDED
26 
27 #include "RemoteGeomProxy.h"
28 #ifdef _DEBUG
29 #include "CmColor.h"
30 #include "FMGiTools.h"
31 //#include "Gi/AECGi.h"
32 #include <Gi/GiGeometry.h>
33 #include <Gi/GiCommonDraw.h>
34 #endif
35 #include "FMProfile2D.h"
36 #include "FMContour2D.h"
37 #include "FMContour3D.h"
38 #include "Modeler/FMDrawBody.h"
39 #include "FMProfile3D.h"
40 #include <Modeler/FMMdlBody.h>
41 #include <Modeler/FMMdlIterators.h>
42 #include "Modeler/FMMdlSurface.h"
43 #include <FMGeometry.h>
44 #include <Int32Array.h>
45 
46 //#include "StaticRxObject.h"
47 #include "../Extensions/ExServices/ExHostAppServices.h"
48 #include "AbstractViewPE.h"
49 //#include "DbEntity/AECDbMassElem.h"
50 #include "Ge/GeLineSeg3d.h"
51 #include "CmColor.h"
52 //#include "DbBlockReference.h"
53 #include <vector>
54 
55 using namespace FacetModeler;
56 
57 // colors are indices to OdCmEntityColor
58 struct DbgColor
59 {
60  static const OdUInt16 clear = 0;
61  static const OdUInt16 red = 1;
62  static const OdUInt16 yellow = 2;
63  static const OdUInt16 green = 3;
64  static const OdUInt16 cyan = 4;
65  static const OdUInt16 blue = 5;
66  static const OdUInt16 magenta = 6;
67  static const OdUInt16 white = 7;
68 };
69 
70 
71 template<typename T>
73 {
74  T m_uColor;
75 
76 public:
78  {
79  m_uColor = 0;
80  }
81 
82  T color()
83  {
84  T nRet = m_uColor;
85 
86  m_uColor++;
87  if(m_uColor > 6)
88  m_uColor = 0;
89 
90  return nRet;
91  }
92 
93  T peekColor() const { return m_uColor; }
94 };
95 
97 
98 #ifdef _DEBUG
99 // Do not change this initialization of the g_DEBUG_DRAW_ENABLED.
100 // Set it to 'true' either in debugger or in sources exactly before DEBUG_DRAW() functions calls
101 static bool g_DEBUG_DRAW_ENABLED = true;
102 
103 template <class TSegment2d>
104 inline void _debug_draw( OdGiWorldGeometry& geom, const TSegment2d& rSeg ) {
105  if( OdZero( rSeg.bulge() ) || rSeg.type() == FacetModeler::estCoincident )
106  {
107  OdGePoint2d pts[2];
108  pts[0] = rSeg.startPt();
109  pts[1] = rSeg.endPt();
110  OdGiTools::polyline2d( geom, 2, pts );
111  }
112  else
113  {
114  //double dBulge = rSeg.bulge();
115  //FacetModeler::SegmentType st = rSeg.type();
116 
118  rSeg.getArcSeg( arc2d );
119  OdGiTools::arc2d( geom, arc2d );
120  }
121 }
122 
123 template <class TSegment2d>
124 inline void DEBUG_DRAW(const TSegment2d& rSeg, OdInt16 color) {
125  if( g_DEBUG_DRAW_ENABLED ) {
126  OdRemoteGeomProxy proxy;
127  OdRemoteGeomProxyAutoBlock rAuto(proxy);
128 
129  proxy.begin();
130  proxy.traits().setColor( color );
131  _debug_draw( proxy.wGeom(), rSeg );
132  proxy.end();
133  }
134 }
135 
136 
137 
138 inline void DEBUG_DRAW3(OdRemoteGeomProxy& proxy, const FacetModeler::Contour2D& contour, OdInt16 color)
139 {
140  proxy.traits().setColor( color );
141 
142  double dBulge = 0;
143 
144  OdUInt32 nSegments = contour.numSegments();
145  for ( OdUInt32 i = 0; i < nSegments; ++i )
146  {
147  contour.getBulgeAt( i, dBulge );
148  if( OdZero( dBulge ) ) {
149  OdGeLineSeg2d line;
150  contour.getLineSegAt( i, line );
151  OdGiTools::lineSeg2d( proxy.wGeom(), line, i );
152  }
153  else {
155  contour.getArcSegAt( i, arc2d );
156  OdGiTools::arc2d( proxy.wGeom(), arc2d, i );
157  }
158  }
159 }
160 
161 inline void DEBUG_DRAW3(OdRemoteGeomProxy& proxy, const FacetModeler::CachedContour2D& contour, OdInt16 color)
162 {
163  proxy.traits().setColor( color );
164 
165  double dBulge = 0;
166 
167  OdUInt32 nSegments = contour.numSegments();
168  for ( OdUInt32 i = 0; i < nSegments; ++i )
169  {
170  contour.getBulgeAt( i, dBulge );
171  if( OdZero( dBulge ) ) {
172  OdGeLineSeg2d line;
173  contour.getLineSegAt( i, line );
174  OdGiTools::lineSeg2d( proxy.wGeom(), line, i );
175  }
176  else {
178  contour.getArcSegAt( i, arc2d );
179  OdGiTools::arc2d( proxy.wGeom(), arc2d, i );
180  }
181  }
182 }
183 
184 inline void DEBUG_DRAW( const FacetModeler::Contour2D& contour, OdInt16 color) {
185  if( g_DEBUG_DRAW_ENABLED ) {
186  OdRemoteGeomProxy proxy;
187  OdRemoteGeomProxyAutoBlock rAuto(proxy);
188 
189  proxy.begin();
190  DEBUG_DRAW3( proxy, contour, color );
191  proxy.end();
192  }
193 }
194 
195 inline void DEBUG_DRAW( const FacetModeler::IContour2D& contour, OdInt16 color)
196 {
197  if( !g_DEBUG_DRAW_ENABLED )
198  return;
199 
200  FacetModeler::Contour2D c2d ( contour );
201 
202  OdRemoteGeomProxy proxy;
203  OdRemoteGeomProxyAutoBlock rAuto(proxy);
204 
205  proxy.begin();
206  DEBUG_DRAW3( proxy, c2d, color );
207  proxy.end();
208 }
209 
210 
211 inline void DEBUG_DRAW( const FacetModeler::CachedContour2D& contour, OdInt16 color) {
212  if( g_DEBUG_DRAW_ENABLED ) {
213  OdRemoteGeomProxy proxy;
214  OdRemoteGeomProxyAutoBlock rAuto(proxy);
215 
216  proxy.begin();
217  DEBUG_DRAW3( proxy, contour, color );
218  proxy.end();
219  }
220 }
221 
222 inline void DEBUG_DRAW(const FacetModeler::Contour3D& contour, OdInt16 color ) {
223  if( g_DEBUG_DRAW_ENABLED ) {
224  OdRemoteGeomProxy proxy;
225  OdRemoteGeomProxyAutoBlock rAuto(proxy);
226 
227  proxy.begin();
228  proxy.wGeom().pushModelTransform( contour.transform() );
229  DEBUG_DRAW3( proxy, static_cast<const FacetModeler::Contour2D&>( contour ), color );
230  proxy.wGeom().popModelTransform();
231  proxy.end();
232  }
233 }
234 
235 inline void DEBUG_DRAW( const FacetModeler::Profile3D& profile, OdInt16 color ) {
236  if( g_DEBUG_DRAW_ENABLED ) {
237  OdRemoteGeomProxy proxy;
238  OdRemoteGeomProxyAutoBlock rAuto(proxy);
239 
240  proxy.begin();
241  proxy.traits().setColor( color );
242 
243  for(OdUInt32 nContour = 0; nContour < profile.size(); nContour++)
244  {
245  const FacetModeler::Contour2D& c2d = profile[nContour] ;
246  for(OdUInt32 nSeg = 0; nSeg < c2d.numSegments(); nSeg++)
247  {
249  c2d.getSegmentAt(nSeg, sg);
250 
251  OdGePoint3d pt3d[2];
252  profile.to3D(sg.startPt(), pt3d[0]);
253  profile.to3D(sg.endPt(), pt3d[1]);
254 
255  proxy.wGeom().polyline( 2, pt3d );
256 #if 1
257  OdUInt16 colorOld = proxy.traits().color();
258  proxy.traits().setColor(1);
259  pt3d[1] = pt3d[0] + (pt3d[1] - pt3d[0]) * 0.1;
260  proxy.wGeom().polyline(2, pt3d);
261  proxy.traits().setColor(colorOld);
262 #endif
263  }
264  }
265 
266  proxy.end();
267  }
268 }
269 
270 inline void DEBUG_DRAW_LINESEG(const OdGePoint2d& pt1, const OdGePoint2d& pt2, OdInt16 color)
271 {
272  OdRemoteGeomProxy proxy;
273  OdRemoteGeomProxyAutoBlock rAuto(proxy);
274 
275  proxy.begin();
276  proxy.traits().setColor( color );
277  OdGePoint2d pts[2];
278  pts[0] = pt1;
279  pts[1] = pt2;
280  OdGiTools::polyline2d( proxy.wGeom(), 2, pts );
281  proxy.end();
282 }
283 
284 inline void DEBUG_DRAW_LINE(const OdGeLine2d& aLine, OdInt16 color)
285 {
286  if( !g_DEBUG_DRAW_ENABLED )
287  return;
288 
289  OdRemoteGeomProxy proxy;
290  OdRemoteGeomProxyAutoBlock rAuto(proxy);
291 
292  const double dMult = 100000.0;
293  OdGePoint2d ptS2d = aLine.pointOnLine() - aLine.direction() * dMult;
294  OdGePoint2d ptE2d = aLine.pointOnLine() + aLine.direction() * dMult;
295 
296  DEBUG_DRAW_LINESEG(ptS2d, ptE2d, color);
297 
298  /*OdGePoint3d pt1(OdGePlane::kXYPlane, ptS2d);
299  OdGePoint3d pt2(OdGePlane::kXYPlane, ptE2d);
300 
301  proxy.begin();
302  proxy.traits().setColor( color );
303  proxy.wGeom().xline(pt1, pt2);
304  proxy.end();*/
305 }
306 
307 inline void DEBUG_DRAW(const OdGeLine2d& aLine, const OdGePlane& aPlane, OdInt16 color)
308 {
309  if( !g_DEBUG_DRAW_ENABLED )
310  return;
311 
312  OdRemoteGeomProxy proxy;
313  OdRemoteGeomProxyAutoBlock rAuto(proxy);
314 
315  FacetModeler::Contour3D cLineRep( aPlane );
316 
317  const double dMult = 100000.0;
318  OdGePoint2d ptS2d = aLine.pointOnLine() - aLine.direction() * dMult;
319  OdGePoint2d ptE2d = aLine.pointOnLine() + aLine.direction() * dMult;
320 
321  cLineRep.appendVertex(ptS2d);
322  cLineRep.appendVertex(ptE2d);
323 
324  DEBUG_DRAW(cLineRep, color);
325 };
326 
327 inline void DEBUG_DRAW(const OdCmEntityColor& color)
328 {
329  if( !g_DEBUG_DRAW_ENABLED )
330  return;
331 
332  OdRemoteGeomProxy proxy;
333  OdRemoteGeomProxyAutoBlock rAuto(proxy);
334 
335  proxy.begin();
336  proxy.traits().setTrueColor( color );
338 
339 
340  static const double fMarkerSize = 100;
341  OdGePoint2d pts[7];
342  pts[0] = OdGePoint2d(-fMarkerSize, fMarkerSize);
343  pts[1] = OdGePoint2d(fMarkerSize, fMarkerSize);
344  pts[2] = OdGePoint2d(fMarkerSize, -fMarkerSize);
345  pts[3] = OdGePoint2d(-fMarkerSize, -fMarkerSize);
346  pts[4] = OdGePoint2d(-fMarkerSize, fMarkerSize);
347  pts[5] = OdGePoint2d(0, -fMarkerSize);
348  pts[6] = OdGePoint2d(fMarkerSize, fMarkerSize);
349 
350  OdGiTools::polyline2d( proxy.wGeom(), 7, pts );
351 
352  proxy.end();
353 }
354 
355 inline void DEBUG_DRAW1(const OdCmColor& color)
356 {
357  DEBUG_DRAW(color.entityColor());
358 };
359 
360 inline void DEBUG_DRAW_POLYLINE(const OdGePoint3d* ptPoly, OdUInt32 nPts, OdInt16 color) {
361  if( g_DEBUG_DRAW_ENABLED ) {
362  OdRemoteGeomProxy proxy;
363  OdRemoteGeomProxyAutoBlock rAuto(proxy);
364 
365  proxy.begin();
366  proxy.traits().setColor( color );
367  proxy.wGeom().polyline(nPts, ptPoly);
368  proxy.end();
369  }
370 }
371 
372 inline void DEBUG_DRAW_TRIANGLE(const OdGePoint3d* ptTriangle, OdInt16 color)
373 {
374  if( !g_DEBUG_DRAW_ENABLED )
375  return;
376 
377  OdRemoteGeomProxy proxy;
378  OdRemoteGeomProxyAutoBlock rAuto(proxy);
379 
380  proxy.begin();
381  proxy.traits().setColor( color );
382  proxy.wGeom().polygon(3, ptTriangle);
383  proxy.end();
384 }
385 
386 inline void DEBUG_DRAW( const FacetModeler::Profile2D& profile, OdInt16 color )
387 {
388  if( g_DEBUG_DRAW_ENABLED ) {
389  OdRemoteGeomProxy proxy;
390  OdRemoteGeomProxyAutoBlock rAuto(proxy);
391 
392  proxy.begin();
393  proxy.traits().setColor( color );
394 
395  OdUInt32 i, iSize = profile.size();
396  for( i = 0; i <iSize; i++ )
397  {
398  OdUInt32 j, jSize = profile[ i ].numSegments();
399  for( j = 0; j < jSize; j++ )
400  {
402  profile[ i ].getSegmentAt( j, seg );
403  _debug_draw( proxy.wGeom(), seg );
404  }
405  }
406 
407  proxy.end();
408  }
409 }
410 
411 inline void DEBUG_DRAW( const std::vector<FacetModeler::Profile2D>& rProfiles, OdInt16 color )
412 {
413  if( !g_DEBUG_DRAW_ENABLED )
414  return;
415 
416  for(size_t idx = 0; idx < rProfiles.size(); idx++)
417  {
418  DEBUG_DRAW(rProfiles[idx], color);
419  }
420 }
421 
422 inline void DEBUG_DRAW3(const OdGePoint3d& pt1, const OdGePoint3d& pt2, OdInt16 color)
423 {
424  if( g_DEBUG_DRAW_ENABLED ) { // set this flag in debugger to enable geometry sending to remote viever
425  OdRemoteGeomProxy proxy;
426  OdRemoteGeomProxyAutoBlock rAuto(proxy);
427 
428  proxy.begin(); // initialize proxy for remote OdGiWorldDraw object
429  proxy.traits().setColor( color );// use remote OdGiSubEntityTraits
430  OdGePoint3d pts[] = {pt1, pt2};
431  proxy.wGeom().polyline( 2, pts );
432  proxy.end();// send geometry to remote viewer
433  }
434 }
435 
436 inline void DEBUG_DRAW(const OdGeLine3d& line, OdInt16 color)
437 {
438  if(!g_DEBUG_DRAW_ENABLED)
439  return;
440 
441  OdRemoteGeomProxy proxy;
442  OdRemoteGeomProxyAutoBlock rAuto(proxy);
443 
444  const double dLineLength = 10000;
445 
446  OdGePoint3d pt1, pt2;
447  pt1 = line.pointOnLine() + line.direction() * dLineLength;
448  pt2 = line.pointOnLine() - line.direction() * dLineLength;
449 
450 
451  proxy.begin(); // initialize proxy for remote OdGiWorldDraw object
452  proxy.traits().setColor( color );// use remote OdGiSubEntityTraits
453  OdGePoint3d pts[] = {pt1, pt2};
454  proxy.wGeom().polyline( 2, pts );
455  proxy.end();// send geometry to remote viewer
456 }
457 
458 inline void DEBUG_DRAW3(const OdGeVector3d& v1, const OdGeVector3d& v2, OdInt16 color) {
459  DEBUG_DRAW3( (const OdGePoint3d&)v1, (const OdGePoint3d&)v2, color );
460 }
461 
462 static inline void DebugDrawBody( OdRemoteGeomProxy& proxy, const FacetModeler::Body& rBody )
463 {
464  if ( !rBody.isNull() )
465  {
466  FacetModeler::EdgeBodyIterator itEdges(&rBody);
467  while(!itEdges.done())
468  {
469  FacetModeler::Edge* pEdge = itEdges.get();
470  if(pEdge != NULL)
471  {
472  FacetModeler::Edge* pPairEdge = pEdge->next();
473  if(pPairEdge != NULL)
474  {
475  OdGePoint3d ptVtx[2];
476  ptVtx[0] = pEdge->vertex()->point();
477  ptVtx[1] = pPairEdge->vertex()->point();
478 
479  proxy.wGeom().polyline( 2, ptVtx );
480  }
481  }
482 
483  itEdges.next();
484  }
485  }
486 }
487 
488 inline void DEBUG_DRAW( const FacetModeler::Body& body, OdInt16 color )
489 {
490  if( !g_DEBUG_DRAW_ENABLED )
491  return;
492 
493  OdRemoteGeomProxy proxy;
494  OdRemoteGeomProxyAutoBlock rAuto(proxy);
495 
496  proxy.begin(); // initialize proxy for remote OdGiWorldDraw object
497 
498  proxy.traits().setColor( color );// use remote OdGiSubEntityTraits
499  DebugDrawBody( proxy, body );
500 
501  proxy.end();// send geometry to remote viewer
502 }
503 
504 
505 
506 inline void DEBUG_DRAW( const OdGePoint3d& pt, double dSize, OdInt16 color )
507 {
508  if( !g_DEBUG_DRAW_ENABLED )
509  return;
510 
511  OdRemoteGeomProxy proxy;
512  OdRemoteGeomProxyAutoBlock rAuto(proxy);
513 
514  proxy.begin(); // initialize proxy for remote OdGiWorldDraw object
515 
516  const double dSizes = dSize;
517  OdGePoint3d ptOrigin = pt - OdGeVector3d(dSizes/2, dSizes/2, dSizes/2);
518 
519  proxy.traits().setColor( color );// use remote OdGiSubEntityTraits
520  DebugDrawBody( proxy, FacetModeler::Body::box( ptOrigin, OdGeVector3d(dSizes, dSizes, dSizes) ) );
521 
522  proxy.end();// send geometry to remote viewer
523 }
524 
525 inline void DEBUG_DRAW( const FacetModeler::Edge& pEdge, OdInt16 color )
526 {
527  if( !g_DEBUG_DRAW_ENABLED )
528  return;
529 
530  OdRemoteGeomProxy proxy;
531  OdRemoteGeomProxyAutoBlock rAuto(proxy);
532 
533  proxy.begin(); // initialize proxy for remote OdGiWorldDraw object
534  proxy.traits().setColor( color );// use remote OdGiSubEntityTraits
535  OdGePoint3d pts[] = {pEdge.startPoint(), pEdge.endPoint()};
536  proxy.wGeom().polyline( 2, pts );
537  proxy.end();// send geometry to remote viewer
538 
539  DEBUG_DRAW(pEdge.endPoint(), 0.01, color);
540 }
541 
542 inline void DebugDrawFaceEdges(const FacetModeler::Face* pFace, OdInt16 color)
543 {
544  if( !g_DEBUG_DRAW_ENABLED )
545  return;
546 
547  EdgeFaceIterator it(pFace);
548  while(!it.done())
549  {
550  DEBUG_DRAW(*it.get(), color);
551 
552  OdGePoint3d pts = it.get()->startPoint();
553  OdGePoint3d pte = it.get()->endPoint();
554 
555  double d = pts.distanceTo(pte);
556 
557  it.next();
558  }
559 
560 }
561 
562 
563 inline void DEBUG_DRAW( const OdGePoint3d& pt, OdInt16 color )
564 {
565  DEBUG_DRAW(pt, 12.0, color);
566 }
567 
568 inline void DEBUG_DRAW3(const OdGePoint3d& pt, const OdGeVector3d& v, OdInt16 color)
569 {
570  if( g_DEBUG_DRAW_ENABLED )
571  { // set this flag in debugger to enable geometry sending to remote viever
572  OdRemoteGeomProxy proxy;
573  OdRemoteGeomProxyAutoBlock rAuto(proxy);
574 
575  const double dLength = v.length();
576  const double dVecLength = dLength * 0.9;
577  OdGePoint3d ptEnd1 = pt + (dVecLength * v);
578  OdGePoint3d ptEnd2 = pt + v;
579 
580  OdGePoint3d pts1[] = {pt, ptEnd1};
581  DEBUG_DRAW_POLYLINE(pts1, 2, color);
582 
583  OdGePoint3d pts2[] = {ptEnd1, ptEnd2};
584  DEBUG_DRAW_POLYLINE(pts2, 2, color+1);
585  }
586 }
587 
588 
589 inline void DEBUG_DRAW( const OdGeLineSeg3d& aSeg, OdInt16 color )
590 {
591  if( g_DEBUG_DRAW_ENABLED ) { // set this flag in debugger to enable geometry sending to remote viever
592  OdRemoteGeomProxy proxy;
593  OdRemoteGeomProxyAutoBlock rAuto(proxy);
594 
595  proxy.begin(); // initialize proxy for remote OdGiWorldDraw object
596  proxy.traits().setColor( color );// use remote OdGiSubEntityTraits
597  OdGePoint3d pts[] = {aSeg.startPoint(), aSeg.endPoint()};
598  proxy.wGeom().polyline( 2, pts );
599  proxy.end();// send geometry to remote viewer
600  }
601 };
602 
603 inline void DEBUG_DRAW_FACE( const FacetModeler::Face* pFace, OdInt16 color ) {
604  if( g_DEBUG_DRAW_ENABLED ) { // set this flag in debugger to enable geometry sending to remote viever
605  OdRemoteGeomProxy proxy;
606  OdRemoteGeomProxyAutoBlock rAuto(proxy);
607 
608  FacetModeler::Profile3D profile;
609  pFace->profile( profile );
610  DEBUG_DRAW( profile, color );
611  }
612 }
613 
614 
615 inline void DEBUG_DRAW_AXIS4(const OdGePoint3d& ptOrigin, const OdGeVector3d& vAxis, const double fLen, OdInt16 color)
616 {
617  OdRemoteGeomProxy proxy;
618  OdRemoteGeomProxyAutoBlock rAuto(proxy);
619 
620  OdGePoint3d v1 = ptOrigin + vAxis * (0.9 * fLen);
621  OdGePoint3d v2 = v1 + vAxis * (0.1 * fLen);
622  DEBUG_DRAW3( ptOrigin, v1, color );
624 }
625 
626 inline void DEBUG_DRAW_AXIS(const OdGePoint3d& ptOrigin, const OdGeVector3d& vAxis, const double fLen) {
627  DEBUG_DRAW_AXIS4(ptOrigin, vAxis, fLen, OdCmEntityColor::kACIGreen);
628 }
629 
630 inline void DEBUG_DRAW_CS(const OdGePoint3d& ptOrigin, const OdGeVector3d& vx, const OdGeVector3d& vy, const OdGeVector3d& vz, const double fLen)
631 {
632  OdRemoteGeomProxy proxy;
633  OdRemoteGeomProxyAutoBlock rAuto(proxy);
634 
635  DEBUG_DRAW_AXIS4(ptOrigin, vx, fLen, OdCmEntityColor::kACIRed);
636  DEBUG_DRAW_AXIS4(ptOrigin, vy, fLen, OdCmEntityColor::kACIGreen);
637  DEBUG_DRAW_AXIS4(ptOrigin, vz, fLen, OdCmEntityColor::kACIBlue);
638 }
639 
640 inline void DEBUG_DRAW_PLANE(const OdGePlane& rPlane, const double fWidth, OdInt16 color)
641 {
642  OdRemoteGeomProxy proxy;
643  OdRemoteGeomProxyAutoBlock rAuto(proxy);
644 
646  c2dBox.appendVertex(OdGePoint2d(-fWidth,-fWidth));
647  c2dBox.appendVertex(OdGePoint2d(fWidth,-fWidth));
648  c2dBox.appendVertex(OdGePoint2d(fWidth,fWidth));
649  c2dBox.appendVertex(OdGePoint2d(-fWidth,fWidth));
650  c2dBox.setClosed(true);
651 
652  FacetModeler::Profile3D c3dPlane(rPlane);
653  c3dPlane.as2d().push_back(c2dBox);
654  DEBUG_DRAW( c3dPlane, color );
655  DEBUG_DRAW_AXIS( rPlane.pointOnPlane(), rPlane.normal(), fWidth/2 );
656 }
657 
658 inline void DEBUG_DRAW(const OdGePoint2d& rPoint, OdInt16 color, double fMarkerSize = 5)
659 {
660  OdRemoteGeomProxy proxy;
661  OdRemoteGeomProxyAutoBlock rAuto(proxy);
662 
664 
665  c2dBox.appendVertex(rPoint + OdGeVector2d(fMarkerSize, -fMarkerSize));
666  c2dBox.appendVertex(rPoint + OdGeVector2d(fMarkerSize, fMarkerSize));
667  c2dBox.appendVertex(rPoint + OdGeVector2d(-fMarkerSize, fMarkerSize));
668  c2dBox.appendVertex(rPoint + OdGeVector2d(-fMarkerSize, -fMarkerSize));
669  c2dBox.setClosed(true);
670 
671  DEBUG_DRAW( c2dBox, color );
672 }
673 
674 inline void DEBUG_DRAW_FACE_PROFILE(const FacetModeler::Profile2D& faceProfile)
675 {
676  for(OdUInt32 contourIdx = 0; contourIdx < faceProfile.size(); contourIdx++)
677  {
678  const FacetModeler::Contour2D& currentContour = faceProfile[contourIdx];
679  if(currentContour.isCCW())
680  {
681  DEBUG_DRAW(currentContour, OdCmEntityColor::kACIRed);
682  }
683  else
684  {
685  DEBUG_DRAW(currentContour, OdCmEntityColor::kACIGreen);
686  }
687  }
688 }
689 
690 /*inline void TEST_DRAW_PLANE( const OdGePlane& rPlane, const double fWidth) {
691  FacetModeler::Contour2D c2dBox;
692  c2dBox.appendVertex(OdGePoint2d(-fWidth,-fWidth));
693  c2dBox.appendVertex(OdGePoint2d(fWidth,-fWidth));
694  c2dBox.appendVertex(OdGePoint2d(fWidth,fWidth));
695  c2dBox.appendVertex(OdGePoint2d(-fWidth,fWidth));
696  c2dBox.setClosed(true);
697 
698  FacetModeler::Profile3D c3dPlane(rPlane);
699  c3dPlane.as2d().push_back(c2dBox);
700  pGi->Geo().DrawProfile3D(c3dPlane);
701 }*/
702 
703 inline void DEBUG_BLOCK_BEGIN()
704 {
705  OdRemoteGeomProxy proxy;
706  proxy.sendStringToExecute(g_strGeomBlockBegin);
707 }
708 
709 inline void DEBUG_BLOCK_END()
710 {
711  OdRemoteGeomProxy proxy;
712  proxy.sendStringToExecute(g_strGeomBlockEnd);
713 }
714 
715 inline void DEBUG_DRAW_ENTITY_EXTENTS_2D(const OdGeMatrix3d& mEntity, const OdGeExtents3d& mExtents, OdUInt16 color)
716 {
717  OdGePoint3d ptOrigin = mEntity.getCsOrigin();
718 
719  double dL = mExtents.maxPoint().x - mExtents.minPoint().x;
720  double dW = mExtents.maxPoint().y - mExtents.minPoint().y;
721 
722  double dPtSize = 1;
723  {
724  double dMin = odmin(dL, dW);
725  dPtSize = dMin / 10;
726  }
727 
729  DEBUG_DRAW(ptOrigin, dPtSize, 0);
730  OdGePoint3d pts[5];
731 
732  pts[0] = ptOrigin;
733  pts[1] = ptOrigin + mEntity.getCsXAxis() * dL;
734  pts[2] = pts[1] + mEntity.getCsYAxis() * dW;
735  pts[3] = pts[2] - mEntity.getCsXAxis() * dL;
736  pts[4] = pts[3] - mEntity.getCsYAxis() * dW;
737  DEBUG_DRAW_POLYLINE(pts, 5, color);
738  DEBUG_BLOCK_END();
739 }
740 
741 /*inline void DEBUG_DRAW_ENTITY_EXTENTS_2D(AECDbGeoPtr pEntity, const OdGeExtents3d& mExtents, OdUInt16 color)
742 {
743  DEBUG_DRAW_ENTITY_EXTENTS_2D(pEntity->GetMatrix(), mExtents, color);
744 }*/
745 
746 inline void DEBUG_DRAW_CS(const OdGeMatrix3d& m, double dBaseLen, OdUInt16 color)
747 {
748  OdGePoint3d origin;
749  OdGeVector3d xAxis;
750  OdGeVector3d yAxis;
751  OdGeVector3d zAxis;
752  m.getCoordSystem(origin, xAxis, yAxis, zAxis);
753 
755  DEBUG_DRAW(origin, dBaseLen / 10., 0);
756 
757  OdGePoint3d pts[2];
758  pts[0] = origin;
759 
760  pts[1] = origin + xAxis * dBaseLen;
761  DEBUG_DRAW_POLYLINE(pts, 2, color);
762 
763  pts[1] = origin + yAxis * dBaseLen * 3;
764  DEBUG_DRAW_POLYLINE(pts, 2, color);
765 
766  pts[1] = origin + zAxis * dBaseLen * 5;
767  DEBUG_DRAW_POLYLINE(pts, 2, color);
768 
769  DEBUG_BLOCK_END();
770 }
771 
772 /*inline void DEBUG_DRAW(OdDbBlockReference* pBlock, OdUInt16 color)
773 {
774  DEBUG_BLOCK_BEGIN();
775 
776  OdRemoteGeomProxy proxy;
777  OdRemoteGeomProxyAutoBlock rAuto(proxy);
778 
779  proxy.setDatabase(pBlock->database());
780  proxy.begin();
781  proxy.traits().setColor( color );
782  proxy.wGeom().draw( pBlock );
783  proxy.end();
784 
785  DEBUG_BLOCK_END();
786 }*/
787 
788 inline void DEBUG_CONTOUR2D(const FacetModeler::Contour2D& c)
789 {
790  AecAutoColor color;
791  bool fIsSI = c.isSelfIntersecting();
792 
794  const int numSegs = c.numSegments();
795  for(int s = 0; s < numSegs; s++)
796  {
797  c.getSegmentAt(s, aSeg);
798  DEBUG_DRAW(aSeg, color.peekColor());
799 
800  double dBulge = aSeg.bulge();
801  FacetModeler::SegmentType sType = aSeg.type();
802 
803  OdGePoint2d ptS = aSeg.startPt();
804  OdGePoint2d ptE = aSeg.endPt();
805 
806  DEBUG_DRAW(ptS, color.peekColor());
807  DEBUG_DRAW(ptE, color.peekColor());
808 
809  color.color();
810  }
811 
812  OdGePoint2d pt;
813  const int numVerts = c.numVerts();
814  for(int i = 0; i < numVerts; i++)
815  {
816  c.getVertexAt(i, &pt);
817  DEBUG_DRAW(pt, color.color());
818  }
819 }
820 
821 #else
822 
823 
824 inline void DEBUG_DRAW3(OdRemoteGeomProxy& proxy, const Contour2D& contour, OdInt16 color) {}
825 
826 inline void DEBUG_DRAW3(OdRemoteGeomProxy& proxy, const CachedContour2D& contour, OdInt16 color) {}
827 
828 inline void DEBUG_DRAW( const Contour2D& contour, OdInt16 color) {}
829 
830 inline void DEBUG_DRAW( const CachedContour2D& contour, OdInt16 color) {}
831 
832 inline void DEBUG_DRAW(const Contour3D& contour, OdInt16 color ) {}
833 
834 inline void DEBUG_DRAW( const Profile3D& profile, OdInt16 color ) {}
835 
836 inline void DEBUG_DRAW_LINESEG(const OdGePoint2d& pt1, const OdGePoint2d& pt2, OdInt16 color) {}
837 
838 inline void DEBUG_DRAW_LINE(const OdGeLine2d& aLine, OdInt16 color) {}
839 
840 inline void DEBUG_DRAW(const OdGeLine2d& aLine, const OdGePlane& aPlane, OdInt16 color) {}
841 
842 inline void DEBUG_DRAW(const OdCmEntityColor& color) {}
843 
844 inline void DEBUG_DRAW1(const OdCmColor& color) {}
845 
846 inline void DEBUG_DRAW_POLYLINE(const OdGePoint3d* ptPoly, OdUInt32 nPts, OdInt16 color) {}
847 
848 inline void DEBUG_DRAW( const Profile2D& profile, OdInt16 color ) {}
849 
850 inline void DEBUG_DRAW( const std::vector<Profile2D>& rProfiles, OdInt16 color ) {}
851 
852 inline void DEBUG_DRAW3(const OdGePoint3d& pt1, const OdGePoint3d& pt2, OdInt16 color) {}
853 
854 inline void DEBUG_DRAW(const OdGeLine3d& line, OdInt16 color) {}
855 
856 inline void DEBUG_DRAW3(const OdGeVector3d& v1, const OdGeVector3d& v2, OdInt16 color) {}
857 
858 static inline void DebugDrawBody( OdRemoteGeomProxy& proxy, const Body& rBody ) {}
859 
860 inline void DEBUG_DRAW( const Body& body, OdInt16 color ) {}
861 
862 inline void DEBUG_DRAW( const OdGePoint3d& pt, double dSize, OdInt16 color ) {}
863 
864 inline void DEBUG_DRAW( const OdGePoint3d& pt, OdInt16 color ) {}
865 
866 inline void DEBUG_DRAW3(const OdGePoint3d& pt, const OdGeVector3d& v, OdInt16 color) {}
867 
868 
869 inline void DEBUG_DRAW( const OdGeLineSeg3d& aSeg, OdInt16 color ) {}
870 
871 inline void DEBUG_DRAW_FACE( const Face* pFace, OdInt16 color ) {}
872 
873 inline void DEBUG_DRAW( const Edge& pEdge, OdInt16 color ) {}
874 
875 inline void DEBUG_DRAW_AXIS4(const OdGePoint3d& ptOrigin, const OdGeVector3d& vAxis, const double fLen, OdInt16 color) {}
876 
877 inline void DEBUG_DRAW_AXIS(const OdGePoint3d& ptOrigin, const OdGeVector3d& vAxis, const double fLen) {}
878 
879 inline void DEBUG_DRAW_CS(const OdGePoint3d& ptOrigin, const OdGeVector3d& vx, const OdGeVector3d& vy, const OdGeVector3d& vz, const double fLen) {}
880 
881 inline void DEBUG_DRAW_PLANE(const OdGePlane& rPlane, const double fWidth, OdInt16 color) {}
882 
883 inline void DEBUG_DRAW(const OdGePoint2d& rPoint, OdInt16 color, double fMarkerSize = 5) {}
884 inline void DEBUG_DRAW(const Segment2D& rSeg, OdInt16 color) {}
885 
886 inline void DEBUG_DRAW_FACE_PROFILE(const Profile2D& faceProfile) {}
887 
888 //inline void TEST_DRAW_PLANE( AECGiDraw* pGi, const OdGePlane& rPlane, const double fWidth) {}
889 
890 
891 inline void DEBUG_DRAW_ENTITY_EXTENTS_2D(const OdGeMatrix3d& mEntity, const OdGeExtents3d& mExtents, OdUInt16 color) {}
892 
893 //inline void DEBUG_DRAW_ENTITY_EXTENTS_2D(AECDbGeoPtr pEntity, const OdGeExtents3d& mExtents, OdUInt16 color) {}
894 
895 inline void DEBUG_DRAW_CS(const OdGeMatrix3d& m, double dBaseLen, OdUInt16 color) {}
896 
897 
898 //inline void DEBUG_DRAW(OdDbBlockReference* pBlock, OdUInt16 color) {}
899 
900 inline void DEBUG_DRAW_TRIANGLE(const OdGePoint3d* ptTriangle, OdInt16 color) {}
901 
902 inline void DEBUG_CONTOUR2D(const Contour2D& c) {}
903 
904 inline void DEBUG_BLOCK_BEGIN(){}
905 inline void DEBUG_BLOCK_END(){}
906 
907 
908 
909 
910 
911 
912 
913 
914 #endif
915 
916 
917 
918 #endif //#if !defined(DEBUG_DRAW_INCLUDED)
void DEBUG_DRAW_ENTITY_EXTENTS_2D(const OdGeMatrix3d &mEntity, const OdGeExtents3d &mExtents, OdUInt16 color)
Definition: FMDebugDraw.h:891
void DEBUG_DRAW_AXIS4(const OdGePoint3d &ptOrigin, const OdGeVector3d &vAxis, const double fLen, OdInt16 color)
Definition: FMDebugDraw.h:875
void DEBUG_CONTOUR2D(const Contour2D &c)
Definition: FMDebugDraw.h:902
void DEBUG_DRAW_POLYLINE(const OdGePoint3d *ptPoly, OdUInt32 nPts, OdInt16 color)
Definition: FMDebugDraw.h:846
void DEBUG_DRAW_FACE_PROFILE(const Profile2D &faceProfile)
Definition: FMDebugDraw.h:886
void DEBUG_DRAW_PLANE(const OdGePlane &rPlane, const double fWidth, OdInt16 color)
Definition: FMDebugDraw.h:881
void DEBUG_DRAW_LINE(const OdGeLine2d &aLine, OdInt16 color)
Definition: FMDebugDraw.h:838
void DEBUG_DRAW1(const OdCmColor &color)
Definition: FMDebugDraw.h:844
void DEBUG_DRAW_CS(const OdGePoint3d &ptOrigin, const OdGeVector3d &vx, const OdGeVector3d &vy, const OdGeVector3d &vz, const double fLen)
Definition: FMDebugDraw.h:879
void DEBUG_BLOCK_END()
Definition: FMDebugDraw.h:905
void DEBUG_DRAW3(OdRemoteGeomProxy &proxy, const Contour2D &contour, OdInt16 color)
Definition: FMDebugDraw.h:824
void DEBUG_DRAW(const Contour2D &contour, OdInt16 color)
Definition: FMDebugDraw.h:828
void DEBUG_DRAW_LINESEG(const OdGePoint2d &pt1, const OdGePoint2d &pt2, OdInt16 color)
Definition: FMDebugDraw.h:836
void DEBUG_DRAW_FACE(const Face *pFace, OdInt16 color)
Definition: FMDebugDraw.h:871
void DEBUG_DRAW_AXIS(const OdGePoint3d &ptOrigin, const OdGeVector3d &vAxis, const double fLen)
Definition: FMDebugDraw.h:877
TAecAutoColor< OdUInt16 > AecAutoColor
Definition: FMDebugDraw.h:96
void DEBUG_DRAW_TRIANGLE(const OdGePoint3d *ptTriangle, OdInt16 color)
Definition: FMDebugDraw.h:900
void DEBUG_BLOCK_BEGIN()
Definition: FMDebugDraw.h:904
#define NULL
Definition: GsProperties.h:177
#define odmin(X, Y)
Definition: OdPlatform.h:34
unsigned int OdUInt32
short OdInt16
unsigned short OdUInt16
bool OdZero(double x, double tol=1.e-10)
Definition: OdaDefs.h:513
static Body box(const OdGePoint3d &ptOrigin, const OdGeVector3d &vSizes)
bool isNull() const
Result getLineSegAt(OdUInt32 iIndex, OdGeLineSeg2d &geLine) const
Result getBulgeAt(OdUInt32 iIndex, double &dBulge) const
void setClosed(bool bClosed=true)
Result getArcSegAt(OdUInt32 iIndex, OdGeCircArc2d &geArc) const
OdUInt32 numVerts() const
bool isSelfIntersecting(const OdGeTol &gTol=FMGeGbl::gTol, bool bExcludeTouch=false) const
Result getVertexAt(OdUInt32 iIndex, OdGePoint2d *pPoint, double *pBulge=0, OdIntPtr *pMetadata=0, OdUInt32 *puRawFlags=0) const
Result getSegmentAt(OdUInt32 iIndex, Segment2D &rSegment) const
OdUInt32 numSegments() const
Result appendVertex(const OdGePoint2d &ptStart, double dBulge=0.0, OdIntPtr uMetadata=0, OdUInt32 uRawFlags=0)
const OdGePoint3d & startPoint() const
Definition: FMMdlEdge.h:262
const OdGePoint3d & endPoint() const
Definition: FMMdlEdge.h:266
FacetModeler::Vertex * vertex() const
Edge * next() const
void profile(Profile3D &rResult, const OdGePlane *pPlane=0, bool bIncludeHoles=true) const
size_type size() const
DOM.
const OdGePoint2d & startPt() const
const OdGePoint2d & endPt() const
double bulge() const
SegmentType type() const
const OdGePoint3d & point() const
const OdGeMatrix3d & transform() const
void to3D(const OdGePoint2d &rSource2D, OdGePoint3d &rDest3D) const
OdCmEntityColor entityColor() const
const OdGePoint3d & maxPoint() const
Definition: GeExtents3d.h:242
const OdGePoint3d & minPoint() const
Definition: GeExtents3d.h:237
OdGePoint3d startPoint() const
OdGePoint3d endPoint() const
OdGePoint2d pointOnLine() const
OdGeVector2d direction() const
OdGeVector3d direction() const
OdGePoint3d pointOnLine() const
void getCoordSystem(OdGePoint3d &origin, OdGeVector3d &xAxis, OdGeVector3d &yAxis, OdGeVector3d &zAxis) const
OdGePoint3d getCsOrigin() const
OdGeVector3d getCsYAxis() const
OdGeVector3d getCsXAxis() const
OdGePoint3d pointOnPlane() const
OdGeVector3d normal() const
double distanceTo(const OdGePoint3d &point) const
double y
Definition: GePoint3d.h:368
double x
Definition: GePoint3d.h:367
virtual void popModelTransform()=0
virtual void polyline(OdInt32 numVertices, const OdGePoint3d *vertexList, const OdGeVector3d *pNormal=0, OdGsMarker baseSubEntMarker=-1)=0
virtual void polygon(OdInt32 numVertices, const OdGePoint3d *vertexList)=0
virtual void pushModelTransform(const OdGeVector3d &normal)=0
virtual OdUInt16 color() const =0
virtual void setLineWeight(OdDb::LineWeight lineWeight)=0
virtual void setColor(OdUInt16 color)=0
virtual void setTrueColor(const OdCmEntityColor &color)=0
OdGiSubEntityTraits & traits()
void sendStringToExecute(const OdString &s)
OdGiWorldGeometry & wGeom()
T peekColor() const
Definition: FMDebugDraw.h:93
GLfloat GLfloat v1
Definition: gles2_ext.h:295
GLfloat GLfloat GLfloat v2
Definition: gles2_ext.h:296
const GLfloat * v
Definition: gles2_ext.h:315
GLfloat GLfloat blue
Definition: gles2_ext.h:147
GLfloat green
Definition: gles2_ext.h:147
@ kLnWt211
Definition: OdaDefs.h:406
void polyline2d(OdGiGeometry &geom, int n, const OdGePoint2d *pts, double z=0.0)
Definition: FMGiTools.h:32
void lineSeg2d(OdGiGeometry &geom, const OdGeLineSeg2d &line, double z=0.0)
Definition: FMGiTools.h:66
void arc2d(OdGiGeometry &geom, const OdGePoint2d &p1, const OdGePoint2d &p2, const OdGePoint2d &p3, double z=0.0)
Definition: FMGiTools.h:43