CFx SDK Documentation  2023 SP0
GiBaseVectorizerImpl.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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-2017 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 #ifndef __OD_GI_BASE_VECTORIZER_IMPL_H_
25 #define __OD_GI_BASE_VECTORIZER_IMPL_H_
26 
27 #include "TD_PackPush.h"
28 
29 #include "Gs/GsExport.h"
30 #include "Gi/GiBaseVectorizer.h"
32 #include "Gi/GiLinetypeRedir.h"
34 #include "Ps/PlotStyles.h"
35 #include "Gs/GsViewPropsDef.h"
36 #include "Gs/GsViewImpl.h"
37 //FELIX_CHANGE_BEGIN
38 #include "RxObjectImpl.h"
39 #include "RxDictionary.h"
40 #include "RxVariantValue.h"
41 //FELIX_CHANGE_END
42 
50 {
51 protected:
53 
54 public:
56 
61  virtual void setUp(OdGsViewImpl& view);
62 
63  OdGsViewImpl& view() const { ODA_ASSERT(m_view); return *m_view; }
108  OdUInt32 awareFlags() const { return m_nAwareFlags; }
109 
154  OdUInt32 &awareFlags() { return m_nAwareFlags; }
155 
163  {
164  //NS: traits processing was optimized, but it is not correct
165  //Aware flags can be changed when calulating for effective traits in affectTraits(),
166  //but on the other hand the flags are reset independently.
167  //As a result it is possible that aware flags have no kVpFrozenLayers flag set, but
168  //the traits are based on the layer (effective traits are used, unchanged from
169  //the previously processed entity.
170 #ifdef ENABLE_GITRAITSOPTIMIZATION
171  if(GETBIT(m_nAwareFlags, kVpFrozenLayers))
172  resetEntityTraitsData(); //force resetting traits
173 #endif
174  m_nAwareFlags = 0;
175  }
180 
182 
184 
185  void setLinetypesEnabled(bool bEnable);
186  bool isLinetypesEnabled() const;
187 
188  void setModelSection(OdGiDrawable* pSection, bool bUseSectionGeometryMap);
189  const OdGiDrawable* liveSection() const { return m_liveSection; }
190 
193 
195 
200  int lineweightToPixels(OdDb::LineWeight lineweight) const;
201 
206  double lineweightToPixels(double lineweight) const;
207 
208  bool hasLineweightOverride() const;
209  bool hasLinestyleOverride() const;
211 
218 
221 
222  virtual bool isPerspective() const;
223  virtual bool doPerspective(OdGePoint3d& point) const;
224  virtual bool doInversePerspective(OdGePoint3d& point) const;
226  const OdGePoint3d& point,
227  OdGePoint2d& pixelDensity,
228  bool includePerspective = true) const;
229 
231  virtual OdGePoint3d getCameraTarget() const;
233  virtual OdGeVector3d viewDir() const;
234  virtual OdUInt32 viewportId() const;
235  virtual OdInt16 acadWindowId() const;
236  virtual void getViewportDcCorners(
237  OdGePoint2d& lowerLeft,
238  OdGePoint2d& upperRight) const;
240  bool& clipFront,
241  bool& clipBack,
242  double& front,
243  double& back) const;
244  virtual double linetypeScaleMultiplier() const;
245  virtual double linetypeGenerationCriteria() const;
246  virtual bool layerVisible(
247  OdDbStub* layerId) const;
248 
250 
253  virtual void pushModelTransform(const OdGeVector3d& normal);
254  virtual void pushModelTransform(const OdGeMatrix3d & xfm);
255  virtual void popModelTransform();
256  virtual void xline(const OdGePoint3d& firstPoint, const OdGePoint3d& secondPoint);
257  virtual void ray(const OdGePoint3d& basePoint, const OdGePoint3d& throughPoint);
258  virtual void shell(OdInt32 numVertices, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList,
259  const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0);
260  virtual void mesh(OdInt32 numRows, OdInt32 numColumns, const OdGePoint3d* vertexList,
261  const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0);
262 
265  virtual void setExtents(const OdGePoint3d *newExtents);
266 
269  virtual double deviation(const OdGiDeviationType deviationType,
270  const OdGePoint3d& pointOnCurve) const;
271  virtual OdGiRegenType regenType() const;
272 
275  virtual OdUInt32 sequenceNumber() const;
276  virtual bool isValidId(const OdUInt32 viewportId) const;
277  virtual OdDbStub* viewportObjectId() const;
278  virtual OdGiViewport& viewport() const;
279 
282  virtual void setFillPlane(const OdGeVector3d* pNormal = 0);
283  virtual void setFillType(OdGiFillType fillType);
284  virtual OdUInt32 setupForEntity() const;
285  virtual bool pushLineweightOverride(const OdGiLineweightOverride *pOverride);
286  virtual void popLineweightOverride();
287 
290  virtual const OdGiViewport* giViewport() const;
291  virtual const OdGsView* gsView() const;
292  virtual double annotationScale() const;
293 
296  virtual void beginViewVectorization();
297  virtual void endViewVectorization();
298  virtual void onTraitsModified();
299 
300 protected:
304  bool useFillPlane() const;
305 
306  inline bool isOutputSuppressed() const;
307 
312 
313  bool isSupportPlotStyles() const;
314 
317  virtual void affectTraits(const OdGiSubEntityTraitsData* pSource,
318  OdGiSubEntityTraitsData& destination) const;
319 
320  double lineweightToPixelsOverride(OdDb::LineWeight lineweight, bool bAbsolute = false) const;
322  double lineweightToPixelsOverride(double lineweight, bool bAbsolute = false) const;
323 
324  virtual void updateLineweightOverride(const OdGiLineweightOverride &lwdOverride);
325 private:
326  const OdPsPlotStyleData& plotStyle() const;
327  void affect2dTraits(const OdGiSubEntityTraitsData* pFrom, OdGiSubEntityTraitsData& to) const;
333  void updateXlineNRayClipper();
334  void onModelToEyeChanged();
335 
336 protected:
347  OdRxObjectPtr m_pGsReserved; // Reserved pointer for internal use (binary incompatible changes), do not delete.
352 
354 
355 private:
356  OdGsViewImpl* m_view;
357  OdGiConveyorConnector m_ltpEntryPoint;
358 
359  mutable int m_nPenIndex;
360  mutable OdDbStub* m_psnId;
361  mutable OdPsPlotStyleData m_effectivePlotStyle;
362 
363  OdArray<OdGiLineweightOverride, OdMemoryAllocator<OdGiLineweightOverride> > m_lwdOverrideStack; // Lineweight overrides stack
364 protected:
366 protected:
367  enum Flags
368  {
369  kFillPlaneSet = OdGiBaseVectorizer::kLastFlag << 1,
370  kLinetypeContinuous = OdGiBaseVectorizer::kLastFlag << 2,
371  kModelCache = OdGiBaseVectorizer::kLastFlag << 3,
372  kHighlighted = OdGiBaseVectorizer::kLastFlag << 4,
373  kDontAbortRegen = OdGiBaseVectorizer::kLastFlag << 5,
374  kCheckLinePattern = OdGiBaseVectorizer::kLastFlag << 6,
375  kBreakSelection = OdGiBaseVectorizer::kLastFlag << 7,
376  kSuppressOutput = OdGiBaseVectorizer::kLastFlag << 8,
377  kSelectionGeometry = OdGiBaseVectorizer::kLastFlag << 9, // Processing geometry which is intended only for selection
378  kSelectionDisabled = OdGiBaseVectorizer::kLastFlag << 10, // Processing geometry which shouldn't be used for selection
379  kObjectToDeviceValid = OdGiBaseVectorizer::kLastFlag << 11,
380  kDisableInfiniteGeomExtents = OdGiBaseVectorizer::kLastFlag << 12,
381  kSectionableGeomExtentsOnly = OdGiBaseVectorizer::kLastFlag << 13,
382  kDisableSection = OdGiBaseVectorizer::kLastFlag << 14,
383  kSectionForegroundGeometry = OdGiBaseVectorizer::kLastFlag << 15,
384  kInitGsState = OdGiBaseVectorizer::kLastFlag << 16,
385  kSetVpLtypeScaleMult = OdGiBaseVectorizer::kLastFlag << 17,
386  kSetVpFilterFunction = OdGiBaseVectorizer::kLastFlag << 18,
387  kLineweightOverride = OdGiBaseVectorizer::kLastFlag << 19,
388  kLinestyleOverride = OdGiBaseVectorizer::kLastFlag << 20,
389  kLastOptionFlag = kLinestyleOverride
390  // Note: m_flags and Flags enum bits is nearly complete utilization. Please don't add new flags here.
391  // use m_implFlags and ImplFlags enum instead.
392  };
394  {
395  kFirstImplFlag = 1,
396  kSectionableGeomEnabled = kFirstImplFlag << 0,
397  kLastImplFlag = kSectionableGeomEnabled
398  };
399 };
400 
401 //FELIX_CHANGE_BEGIN
402 template<typename T, typename>
403 struct identity { typedef T type; };
404 
405 class Foo
406 {
407 public:
408  operator int() const;
409 
410  template <typename T> T get() const {
411  return this->identity<Foo, T>::type::operator T();
412  }
413 };
414 
415 template < class _DataTy, class _TraitsTy >
417  : public _TraitsTy
418 {
419 public:
420  static _DataTy getNull()
421  {
422  return _DataTy( 0 );
423  }
424 };
425 
426 template < class _DataTy, class _TraitsTy >
428 {
429 public:
430  typedef _TraitsTy Traits;
431  static void removeFromDevice( OdGsDevice *device )
432  {
433  if ( !device )
434  return;
435  OdRxDictionaryPtr dict = device->properties();
436  if ( dict.isNull() )
437  return;
438  dict->remove( Traits::key() );
439  }
440  static _DataTy fromDevice( OdGsDevice *device, bool *isValid = 0 )
441  {
442  if ( !device )
443  {
444  if (isValid)
445  *isValid = false;
446  return _DataTy();
447  }
448  OdRxDictionaryPtr dict = device->properties();
449  if ( dict.isNull() )
450  {
451  if (isValid)
452  *isValid = false;
453  return _DataTy();
454  }
455  OdRxVariantValue val(( dict->getAt( Traits::key() ) )) ;
456  bool isNull = val.isNull();
457  if (isValid)
458  *isValid = !isNull;
459  return isNull ? ( _DataTy )Traits::getNull() : val.identity< OdRxVariantValue, _DataTy >::type::operator _DataTy();
460  }
461  static void toDevice( OdGsDevice *device, const _DataTy &val )
462  {
463  if ( !device )
464  return;
465  OdRxDictionaryPtr dict = device->properties();
466  if ( dict.isNull() )
467  return;
468  dict->putAt( Traits::key(), OdRxVariantValue( val ) );
469  }
470 };
471 
472 template < class _DataTy, class _TraitsTy >
474  : public CFxDeviceProperty< _DataTy, CFxPropertyIntegralTraits< _DataTy, _TraitsTy > >
475 {
476 };
477 
478 template < class _DataTy, class _StorageTy, class _TraitsTy >
480  : public CFxDeviceProperty< _StorageTy, CFxPropertyIntegralTraits< _DataTy, _TraitsTy > >
481 {
482 public:
484  static _DataTy fromDevice( OdGsDevice *device, bool *isValid = 0 )
485  {
486  return (_DataTy)_BaseTy::fromDevice( device, isValid );
487  }
488  static void toDevice( OdGsDevice *device, const _DataTy &val )
489  {
490  _StorageTy stor(val);
491  return _BaseTy::toDevice(device, val);
492  }
493 };
494 
495 template < class _DataTy, class _TraitsTy, class _PtrTy = OdUInt64 >
497  : public CFxDeviceProperty< _PtrTy, CFxPropertyIntegralTraits< _DataTy *, _TraitsTy > >
498 {
499 public:
501  static _DataTy *allocateAt( OdGsDevice *device, const _DataTy &def )
502  {
503  if ( !device )
504  return 0;
505  _DataTy *p = ( _DataTy * )Base::fromDevice( device );
506  if ( !p )
507  {
508  p = new _DataTy( def );
509  toDevice( device, p );
510  }
511  return p;
512  }
513  static _DataTy *allocateAt( OdGsDevice *device )
514  {
515  if ( !device )
516  return 0;
517  _DataTy *p = ( _DataTy * )Base::fromDevice( device );
518  if ( !p )
519  {
520  p = new _DataTy();
521  toDevice( device, p );
522  }
523  return p;
524  }
525  static void deallocateAt( OdGsDevice *device )
526  {
527  if ( !device )
528  return;
529  _DataTy *p = ( _DataTy * )Base::fromDevice( device );
530  Base::removeFromDevice( device );
531  delete p;
532  }
533  static _DataTy *fromDevice( OdGsDevice *device, bool *isValid = 0 )
534  {
535  if ( !device )
536  return 0;
537  return ( _DataTy * )Base::fromDevice( device, isValid );
538  }
539  static void toDevice( OdGsDevice *device, const _DataTy *val )
540  {
541  return Base::toDevice( device, ( _PtrTy ) val );
542  }
543 };
544 class GS_TOOLKIT_EXPORT CFxPlotGenerationDeviceProperty // Just hints, treat as minimum desired quality settings.
545 {
546 public:
547  static const OdString key()
548  {
549  return OdString( OD_T("IsPlotGeneration") );
550  }
551 };
552 
553 class GS_TOOLKIT_EXPORT CFxRenderHints // Just hints, treat as minimum desired quality settings.
554 {
555 public:
556  static const OdString key()
557  {
558  return OdString( OD_T("FxRenderHints") );
559  }
560  CFxRenderHints() : geomDpi( 0 ), colorImgDpi( 0 ), bwImgDpi( 0 ), deviceToMmRatio( 1., 1. )
561  { }
562  int geomDpi, colorImgDpi, bwImgDpi;
564 };
565 
567  : public CFxDevicePropertyIntegral< bool, CFxPlotGenerationDeviceProperty >
568 {
569 };
571  : public CFxDevicePropertyPtr< CFxRenderHints, CFxRenderHints >
572 {
573 };
574 //FELIX_CHANGE_END
575 
577 {
578  return GETBIT(m_flags, kSuppressOutput);
579 }
580 
582 {
583  if (bEnable) m_pLinetyper->enable();
584  else m_pLinetyper->disable();
585 }
586 
588 {
589  return m_pLinetyper->enabled();
590 }
591 
593 {
595 }
596 
598 {
600  return view().lineweightToPixels(lineweight);
601  return lineweightToPixelsOverrideInt(lineweight);
602 }
603 
604 inline double OdGiBaseVectorizerImpl::lineweightToPixels(double lineweight) const
605 {
607  return view().lineweightToPixels(lineweight);
608  return lineweightToPixelsOverride(lineweight);
609 }
610 
611 inline double OdGiBaseVectorizerImpl::lineweightToPixelsOverride(OdDb::LineWeight lineweight, bool bAbsolute) const
612 {
613  return lineweightToPixelsOverride(double(lineweight) / 100.0, bAbsolute);
614 }
615 
617 {
619  return &m_lwdOverrideStack.last();
620  return NULL;
621 }
622 
624 {
626 }
627 
629 {
631 }
632 
633 #include "TD_PackPop.h"
634 
635 #endif // __OD_GI_BASE_VECTORIZER_IMPL_H_
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:49
OdGiFillType
Definition: Gi.h:40
OdGiRegenType
Definition: GiCommonDraw.h:50
OdGiDeviationType
Definition: GiCommonDraw.h:64
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
#define NULL
Definition: GsProperties.h:177
@ kVpFrozenLayers
#define OD_T(x)
unsigned int OdUInt32
short OdInt16
int OdInt32
OdString OdString
Definition: OdString.h:1224
#define GETBIT(flags, bit)
Definition: OdaDefs.h:500
static _DataTy fromDevice(OdGsDevice *device, bool *isValid=0)
static void toDevice(OdGsDevice *device, const _DataTy &val)
static void removeFromDevice(OdGsDevice *device)
static void toDevice(OdGsDevice *device, const _DataTy &val)
CFxDeviceProperty< _StorageTy, CFxPropertyIntegralTraits< _DataTy, _TraitsTy > > _BaseTy
static _DataTy fromDevice(OdGsDevice *device, bool *isValid=0)
static _DataTy * allocateAt(OdGsDevice *device)
static _DataTy * fromDevice(OdGsDevice *device, bool *isValid=0)
CFxDeviceProperty< _PtrTy, CFxPropertyIntegralTraits< _DataTy *, _TraitsTy > > Base
static void toDevice(OdGsDevice *device, const _DataTy *val)
static void deallocateAt(OdGsDevice *device)
static _DataTy * allocateAt(OdGsDevice *device, const _DataTy &def)
static const OdString key()
OdGeVector2d deviceToMmRatio
T get() const
T & last()
Definition: OdArray.h:1198
bool isNull() const
Definition: BaseObjectPtr.h:70
const OdPsPlotStyleData & effectivePlotStyle() const
OdGiOrthoClipperPtr m_pXlineNRayClipper
OdCmTransparency m_sectForegroundFace
virtual OdGeMatrix3d getWorldToEyeTransform() const
virtual OdGeMatrix3d getEyeToModelTransform() const
int lineweightToPixels(OdDb::LineWeight lineweight) const
OdGsView::RenderMode getRenderMode() const
virtual void mesh(OdInt32 numRows, OdInt32 numColumns, const OdGePoint3d *vertexList, const OdGiEdgeData *pEdgeData=0, const OdGiFaceData *pFaceData=0, const OdGiVertexData *pVertexData=0)
int lineweightToPixelsOverrideInt(OdDb::LineWeight lineweight) const
const OdGiLineweightOverride * currentLineweightOverride() const
OdGsViewImpl & view() const
virtual double linetypeGenerationCriteria() const
virtual void getViewportDcCorners(OdGePoint2d &lowerLeft, OdGePoint2d &upperRight) const
virtual void popModelTransform()
void setModelSection(OdGiDrawable *pSection, bool bUseSectionGeometryMap)
virtual OdInt16 acadWindowId() const
virtual void getNumPixelsInUnitSquare(const OdGePoint3d &point, OdGePoint2d &pixelDensity, bool includePerspective=true) const
virtual double deviation(const OdGiDeviationType deviationType, const OdGePoint3d &pointOnCurve) const
virtual OdGiRegenType regenType() const
virtual OdGePoint3d getCameraLocation() const
OdGeMatrix3d worldToModelTransform() const
virtual bool pushLineweightOverride(const OdGiLineweightOverride *pOverride)
virtual void onTraitsModified()
virtual void setExtents(const OdGePoint3d *newExtents)
virtual const OdGsView * gsView() const
virtual OdGeMatrix3d getWorldToModelTransform() const
bool isEffectiveLinetypeContinuous() const
virtual OdGiViewport & viewport() const
virtual OdUInt32 viewportId() const
virtual void setFillType(OdGiFillType fillType)
virtual void shell(OdInt32 numVertices, const OdGePoint3d *vertexList, OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData=0, const OdGiFaceData *pFaceData=0, const OdGiVertexData *pVertexData=0)
virtual bool doPerspective(OdGePoint3d &point) const
OdPsPlotStyleData m_plotStyle
virtual void affectTraits(const OdGiSubEntityTraitsData *pSource, OdGiSubEntityTraitsData &destination) const
bool useFillPlane() const
virtual OdUInt32 sequenceNumber() const
double lineweightToPixelsOverride(OdDb::LineWeight lineweight, bool bAbsolute=false) const
ODRX_USING_HEAP_OPERATORS(OdGiBaseVectorizer)
virtual void setFillPlane(const OdGeVector3d *pNormal=0)
virtual void xline(const OdGePoint3d &firstPoint, const OdGePoint3d &secondPoint)
virtual OdGeMatrix3d getEyeToWorldTransform() const
OdGiLinetypeRedirPtr m_pLinetyper
const OdGiContextualColors * contextualColors() const
virtual double annotationScale() const
virtual void popLineweightOverride()
virtual OdGeMatrix3d getModelToWorldTransform() const
OdGiConveyorEmbranchmentPtr m_pOutputBranch
virtual bool getFrontAndBackClipValues(bool &clipFront, bool &clipBack, double &front, double &back) const
OdGeMatrix3d modelToWorldTransform() const
virtual void pushModelTransform(const OdGeVector3d &normal)
virtual void setUp(OdGsViewImpl &view)
void setLinetypesEnabled(bool bEnable)
virtual OdUInt32 setupForEntity() const
virtual void beginViewVectorization()
virtual OdGeMatrix3d getModelToEyeTransform() const
virtual OdGeVector3d getCameraUpVector() const
OdCmTransparency m_sectForegroundEdge
virtual OdGePoint3d getCameraTarget() const
virtual bool layerVisible(OdDbStub *layerId) const
const OdGiDrawable * liveSection() const
OdGiConveyorEntryPoint m_xlineNRayEntryPoint
virtual void pushModelTransform(const OdGeMatrix3d &xfm)
virtual OdGeVector3d viewDir() const
virtual OdDbStub * viewportObjectId() const
double lineweightToPixelsOverride(double lineweight, bool bAbsolute=false) const
virtual void endViewVectorization()
virtual void updateLineweightOverride(const OdGiLineweightOverride &lwdOverride)
virtual double linetypeScaleMultiplier() const
virtual bool isValidId(const OdUInt32 viewportId) const
virtual void ray(const OdGePoint3d &basePoint, const OdGePoint3d &throughPoint)
virtual bool isPerspective() const
virtual bool doInversePerspective(OdGePoint3d &point) const
OdGiContext::PStyleType m_pstype
virtual OdGeMatrix3d objectToDeviceMatrix() const
virtual const OdGiViewport * giViewport() const
virtual const OdGiLineweightOverride * currentLineweightOverride() const
virtual bool enabled() const =0
virtual void disable()=0
virtual void enable()=0
@ kHint2DAttributes
Definition: Gi.h:165
virtual OdRxDictionaryPtr properties()=0
Definition: Gs.h:133
RenderMode
Definition: Gs.h:138
int lineweightToPixels(OdDb::LineWeight lineweight) const
virtual OdRxObjectPtr getAt(const OdString &key) const =0
virtual OdRxObjectPtr remove(const OdString &key)=0
virtual OdRxObjectPtr putAt(const OdString &key, OdRxObject *pObject, OdUInt32 *pRetId=0)=0
LineWeight
Definition: OdaDefs.h:384