zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
/////////////////////////////////////////////////////////////////////////////// 
// Copyright (C) 2002-2016, Open Design Alliance (the "Alliance"). 
// All rights reserved. 
// 
// This software and its documentation and related materials are owned by 
// the Alliance. The software may only be incorporated into application 
// programs owned by members of the Alliance, subject to a signed 
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable  
// trade secrets of the Alliance and its suppliers. The software is also 
// protected by copyright law and international treaty provisions. Application  
// programs incorporating this software must include the following statement 
// with their copyright notices:
//   
//   This application incorporates Teigha(R) software pursuant to a license 
//   agreement with Open Design Alliance.
//   Teigha(R) Copyright (C) 2002-2016 by Open Design Alliance. 
//   All rights reserved.
//
// By use of this software, its documentation or related materials, you 
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
 
#ifndef __OD_GI_BASE_VECTORIZER_IMPL_H_
#define __OD_GI_BASE_VECTORIZER_IMPL_H_
 
#include "TD_PackPush.h"
 
#include "Gs/GsExport.h"
#include "Gi/GiBaseVectorizer.h"
#include "Gi/GiConveyorEmbranchment.h"
#include "Gi/GiLinetypeRedir.h"
#include "Ps/PlotStyles.h"
#include "Gs/GsViewPropsDef.h"
#include "Gs/GsViewImpl.h"
 
/** \details
    
    Library: TD_Gs
 
    <group OdGs_Classes> 
*/
class GS_TOOLKIT_EXPORT OdGiBaseVectorizerImpl: public OdGiViewport, public OdGiBaseVectorizer
{
protected:
  ODRX_USING_HEAP_OPERATORS(OdGiBaseVectorizer);
 
public:
  OdGiBaseVectorizerImpl();
 
  /** \details
    This method is to be called when setting up the vectorizer to work
    on the given view.
  *
  */
      virtual void setUp(OdGsViewImpl& view);
 
  OdGsViewImpl& view() const { ODA_ASSERT(m_view); return *m_view; }
  /** \details
    Returns the Aware flags for portion of geometry that had been vectorized
    since last call resetAwareFlags().
 
    \remarks
    awareFlags() returns a combination of zero or more of the following:
 
    <table>
    Name                    Value         Geometry_depends_on
    kVpID                   0x00000001    viewport Id (OdGiViewport::viewportId()).
    kVpRegenType            0x00000002    regeneration type (OdGiCommonDraw::regenType()).
    kVpRenderMode           0x00000004    render mode (OdGsView::mode()).
    kVpWorldToEye           0x00000008    description to come...
    kVpPerspective          0x00000010    description to come...
    kVpResolution           0x00000020    description to come...
    kVpMaxDevForCircle      0x00000040    description to come...
    kVpMaxDevForCurve       0x00000080    description to come...
    kVpMaxDevForBoundary    0x00000100    description to come...
    kVpMaxDevForIsoline     0x00000200    description to come...
    kVpMaxDevForFacet       0x00000400    description to come...
    kVpCamLocation          0x00000800    description to come...
    kVpCamTarget            0x00001000    description to come...
    kVpCamUpVector          0x00002000    description to come...
    kVpCamViewDir           0x00004000    description to come...
    kVpViewport             0x00008000    description to come...
    kVpFrontBack            0x00010000    description to come...
    kVpFrozenLayers         0x00020000    description to come...
    kVpLtypeScaleMult       0x00040000    description to come...
    kEntityRegenDraw        0x00080000    description to come...
    kVpDisableLayoutCache   0x00100000    description to come...
    kVpModelTf              0x00200000    description to come...
    kVpExcludeFromExtMinMax 0x00400000    description to come...
    kSectionable            0x00800000    description to come...
    kVpRenderModule         0x01000000    description to come...
    kVpAnnoScale            0x02000000    description to come...
    kVpFilterFunction       0x04000000    description to come...
    kVpVisualStyle          0x08000000    description to come...
    </table>
 
    \sa
 
    * resetAwareFlags
  */
  OdUInt32 awareFlags() const { return m_nAwareFlags; }
  OdUInt32 &awareFlags() { return m_nAwareFlags; }
 
  /** \details
    Resets the Aware flags.
 
    \sa
    awareFlags
  */
  void resetAwareFlags()
  {
    //NS: traits processing was optimized, but it is not correct
    //Aware flags can be changed when calulating for effective traits in affectTraits(),
    //but on the other hand the flags are reset independently.
    //As a result it is possible that aware flags have no kVpFrozenLayers flag set, but
    //the traits are based on the layer (effective traits are used, unchanged from 
    //the previously processed entity.
#ifdef ENABLE_GITRAITSOPTIMIZATION
    if(GETBIT(m_nAwareFlags, kVpFrozenLayers))
      resetEntityTraitsData(); //force resetting traits
#endif
    m_nAwareFlags = 0;
  }
  /** \details
    Returns the effective plot style for this vectorizer object.
  */
  const OdPsPlotStyleData& effectivePlotStyle() const;
 
  OdGsView::RenderMode getRenderMode() const;
 
  void clearLinetypeCache();
 
  void setModelSection(OdGiDrawable* pSection, bool bUseSectionGeometryMap);
  const OdGiDrawable* liveSection() const { return m_liveSection; }
 
  OdGeMatrix3d modelToWorldTransform() const;
  OdGeMatrix3d worldToModelTransform() const;
 
  OdGeMatrix3d objectToDeviceMatrix() const;
 
  /** OdGiViewport methods *
  */
  virtual OdGeMatrix3d getModelToEyeTransform() const;
  virtual OdGeMatrix3d getEyeToModelTransform() const;
  virtual OdGeMatrix3d getWorldToEyeTransform() const;
  virtual OdGeMatrix3d getEyeToWorldTransform() const;
 
  virtual OdGeMatrix3d getWorldToModelTransform() const;
  virtual OdGeMatrix3d getModelToWorldTransform() const;
 
  virtual bool isPerspective() const;
  virtual bool doPerspective(OdGePoint3d& point) const;
  virtual bool doInversePerspective(OdGePoint3d& point) const;
  virtual void getNumPixelsInUnitSquare(
    const OdGePoint3d& point, 
    OdGePoint2d& pixelDensity,
    bool includePerspective = true) const;
 
  virtual OdGePoint3d getCameraLocation() const;
  virtual OdGePoint3d getCameraTarget() const;
  virtual OdGeVector3d getCameraUpVector() const;
  virtual OdGeVector3d viewDir() const;
  virtual OdUInt32 viewportId() const;
  virtual OdInt16 acadWindowId() const;
  virtual void getViewportDcCorners(
    OdGePoint2d& lowerLeft, 
    OdGePoint2d& upperRight) const;
  virtual bool getFrontAndBackClipValues(
    bool& clipFront, 
    bool& clipBack, 
    double& front, 
    double& back) const;
  virtual double linetypeScaleMultiplier() const;
  virtual double linetypeGenerationCriteria() const;
  virtual bool layerVisible(
    OdDbStub* layerId) const;  
 
  const OdGiContextualColors *contextualColors() const;
 
  /** OdGiGeometry methods *
  */
  virtual void pushModelTransform(const OdGeVector3d& normal);
  virtual void pushModelTransform(const OdGeMatrix3d & xfm);
  virtual void popModelTransform();
  virtual void xline(const OdGePoint3d& firstPoint, const OdGePoint3d& secondPoint);
  virtual void ray(const OdGePoint3d& basePoint, const OdGePoint3d& throughPoint);
  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 void mesh(OdInt32 numRows, OdInt32 numColumns, const OdGePoint3d* vertexList,
                    const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0);
 
  /** OdGiWorldGeometry methods *
  */
  virtual void setExtents(const OdGePoint3d *newExtents);
 
  /** OdGiCommonDraw methods *
  */
  virtual double deviation(const OdGiDeviationType deviationType,
      const OdGePoint3d& pointOnCurve) const;
  virtual OdGiRegenType regenType() const;
  
  /** OdGiViewportDraw methods *
  */
  virtual OdUInt32 sequenceNumber() const;
  virtual bool isValidId(const OdUInt32 viewportId) const;
  virtual OdDbStub* viewportObjectId() const;
  virtual OdGiViewport& viewport() const;
 
  /** OdGiSubEntityTraits methods *
  */
  virtual void setFillPlane(const OdGeVector3d* pNormal = 0);
  virtual void setFillType(OdGiFillType fillType);
  virtual OdUInt32 setupForEntity() const;
 
  /** OdGiConveyorContext methods *
  */
  virtual const OdGiViewport* giViewport() const;
  virtual const OdGsView* gsView() const;
 
  /** OdGiBaseVectorizer methods *
  */
  virtual void beginViewVectorization();
  virtual void endViewVectorization();
  virtual void onTraitsModified();
 
protected:
  /** \details
    Returns true if and only if this VectorizeView object is configured to use a fill plane.
  */
  bool useFillPlane() const;
 
  inline bool isOutputSuppressed() const;
 
  /** \details
    Returns true if and this if the effective linetype generation is continuous for vectorizer object.
  */
  bool isEffectiveLinetypeContinuous() const;
 
  /** OdGiBaseVectorizer methods *
  */
  virtual void affectTraits(const OdGiSubEntityTraitsData* pSource,
      OdGiSubEntityTraitsData& destination) const;
 
private:
  const OdPsPlotStyleData& plotStyle() const;
  void affect2dTraits(const OdGiSubEntityTraitsData* pFrom, OdGiSubEntityTraitsData& to) const;
  /** \details
    Updates the Xline and Ray clipper prior to rendering each Xline and Ray.
    \remarks
    Called by ray() and xline().
  */
  void updateXlineNRayClipper();
  void onModelToEyeChanged();
  
protected:
  mutable OdUInt32            m_nAwareFlags;
  OdGeVector3d                m_fillPlane;
  OdGiContext::PStyleType     m_pstype;
  mutable OdPsPlotStyleData   m_plotStyle;
  OdUInt32                    m_setAttributesHints;
  OdGiOrthoClipperPtr         m_pXlineNRayClipper;
  OdGiConveyorEntryPoint      m_xlineNRayEntryPoint;
  OdGiLinetypeRedirPtr        m_pLinetyper;
  OdGiConveyorEmbranchmentPtr m_pOutputBranch;
  OdRxObjectPtr               m_pGsReserved; // Reserved pointer for internal use (binary incompatible changes), do not delete.
  OdGiDrawablePtr             m_liveSection;
  OdRxObjectPtr               m_sectionGeometryMap;
  OdCmTransparency            m_sectForegroundFace;
  OdCmTransparency            m_sectForegroundEdge;
 
private:
  OdGsViewImpl*               m_view;
  OdGiXformPtr                m_pXToLtp;
  OdGiConveyorConnector       m_ltpEntryPoint;
 
  mutable int                 m_nPenIndex;
  mutable OdDbStub*           m_psnId;
  mutable OdPsPlotStyleData   m_effectivePlotStyle;
 
protected:
  mutable OdGeMatrix3d        m_objectToDeviceMatrix;
protected:
  enum Flags
  {
    kFillPlaneSet               = OdGiBaseVectorizer::kLastFlag <<  1,
    kLinetypeContinuous         = OdGiBaseVectorizer::kLastFlag <<  2,
    kModelCache                 = OdGiBaseVectorizer::kLastFlag <<  3,
    kHighlighted                = OdGiBaseVectorizer::kLastFlag <<  4,
    kDontAbortRegen             = OdGiBaseVectorizer::kLastFlag <<  5,
    kCheckLinePattern           = OdGiBaseVectorizer::kLastFlag <<  6,
    kBreakSelection             = OdGiBaseVectorizer::kLastFlag <<  7,
    kSuppressOutput             = OdGiBaseVectorizer::kLastFlag <<  8,
    kSelectionGeometry          = OdGiBaseVectorizer::kLastFlag <<  9,  // Processing geometry which is intended only for selection
    kSelectionDisabled          = OdGiBaseVectorizer::kLastFlag <<  10, // Processing geometry which shouldn't be used for selection
    kObjectToDeviceValid        = OdGiBaseVectorizer::kLastFlag <<  11,
    kDisableInfiniteGeomExtents = OdGiBaseVectorizer::kLastFlag <<  12,
    kSectionableGeomExtentsOnly = OdGiBaseVectorizer::kLastFlag <<  13,
    kDisableSection             = OdGiBaseVectorizer::kLastFlag <<  14,
    kSectionForegroundGeometry  = OdGiBaseVectorizer::kLastFlag <<  15,
    kInitGsState                = OdGiBaseVectorizer::kLastFlag <<  16,
    kSetVpLtypeScaleMult        = OdGiBaseVectorizer::kLastFlag <<  17,
    kSetVpFilterFunction        = OdGiBaseVectorizer::kLastFlag <<  18,
    kLastOptionFlag             = kSetVpFilterFunction
  };
};
 
inline bool OdGiBaseVectorizerImpl::isOutputSuppressed() const
{
  return GETBIT(m_flags, kSuppressOutput);
}
 
#include "TD_PackPop.h"
 
#endif // __OD_GI_BASE_VECTORIZER_IMPL_H_