CFx SDK Documentation  2020SP3
GiSectionGeometryOutput.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 __ODGISECTIONGEOMETRYOUTPUT_H__
25 #define __ODGISECTIONGEOMETRYOUTPUT_H__
26 
27 #include "Gi/GiEmptyGeometry.h"
28 #include "Gi/GiDummyGeometry.h"
29 #include "RxObjectImpl.h"
30 
31 #include "TD_PackPush.h"
32 
39 {
40  public:
47  {
56  };
57  protected:
58  enum Flags
59  {
60  kOutputClosedPrimitives = 1,
61  kOutputOpenedPrimitives = 2,
62  kClosedPrimitivesAsPolylines = 4,
63  kToleranceOverrideEnabled = 8
64  };
65  protected:
66  SectionGeometryOutputInterface *m_pIface; // Section geometry interface.
67  OdUInt32 m_flags; // Section geometry output flags.
68  OdUInt32 m_overrideFlags; // Traits overrides flags
69  OdGiSubEntityTraitsData m_overrides; // Traits overrides
70  OdGiSubEntityTraitsData m_traits; // Actual traits storage
71  double m_tolOverride; // Section tolerance override.
72  OdGePoint3dArray m_tmpPoints; // Temporary vertexes array
73  public:
74  OdGiSectionGeometryOutput() : m_pIface(NULL), m_flags(kOutputClosedPrimitives), m_overrideFlags(0), m_tolOverride(1.e-10) {}
75 
80 
91  void setInterface(SectionGeometryOutputInterface *pInterface) { m_pIface = pInterface; }
92 
96  bool isClosedSectionsOutputEnabled() const { return GETBIT(m_flags, kOutputClosedPrimitives); }
101  void enableClosedSectionsOutput(bool bSet) { SETBIT(m_flags, kOutputClosedPrimitives, bSet); }
102 
106  bool isOpenedSectionsOutputEnabled() const { return GETBIT(m_flags, kOutputOpenedPrimitives); }
111  void enableOpenedSectionsOutput(bool bSet) { SETBIT(m_flags, kOutputOpenedPrimitives, bSet); }
112 
116  bool isOutputOfClosedSectionsAsPolylinesEnabled() const { return GETBIT(m_flags, kClosedPrimitivesAsPolylines); }
121  void enableOutputOfClosedSectionsAsPolylines(bool bSet) { SETBIT(m_flags, kClosedPrimitivesAsPolylines, bSet); }
122 
126  bool isSectionToleranceOverrideEnabled() const { return GETBIT(m_flags, kToleranceOverrideEnabled); }
127 
131  double sectionToleranceOverride() const { return m_tolOverride; }
132 
136  void setSectionToleranceOverride(double tolOverride) { SETBIT_1(m_flags, kToleranceOverrideEnabled); m_tolOverride = tolOverride; }
137 
141  void resetSectionToleranceOverride() { SETBIT_0(m_flags, kToleranceOverrideEnabled); }
142 
148  {
149  m_overrideFlags = nFlags;
150  }
155  {
156  return m_overrideFlags;
157  }
158 
164  {
165  m_overrides = pData;
166  }
171  {
172  return m_overrides;
173  }
178  {
179  return m_overrides;
180  }
181 
188  virtual void setupTraits(OdGiConveyorContext &context)
189  {
190  if (m_overrideFlags)
191  {
192  // Copy traits settings from current state
193  OdGiSubEntityTraitsToData dataAdaptor(m_traits);
194  OdGiSubEntityTraitsToData::copyTraits(context.subEntityTraits(), dataAdaptor, m_overrideFlags);
195  // Setup traits overrides
196  dataAdaptor.setTraits(m_overrides);
197  OdGiSubEntityTraitsToData::copyTraits(dataAdaptor, context.subEntityTraits(), m_overrideFlags);
198  context.onTraitsModified();
199  }
200  }
201 
208  virtual void releaseTraits(OdGiConveyorContext &context)
209  {
210  if (m_overrideFlags)
211  {
212  // Copy modified traits back to current state
213  OdGiSubEntityTraitsToData dataAdaptor(m_traits);
214  OdGiSubEntityTraitsToData::copyTraits(dataAdaptor, context.subEntityTraits(), m_overrideFlags);
215  //context.onTraitsModified(); // Don't need since we completed with section geometry
216  }
217  }
218 
224  void polylineProc(OdInt32 numPoints, const OdGePoint3d* vertexList, const OdGeVector3d* pNormal = 0,
225  const OdGeVector3d* pExtrusion = 0, OdGsMarker baseSubEntMarker = -1)
226  {
227  setupTraits(getInterface().conveyorContext());
228  getInterface().destinationGeometry().polylineProc(numPoints, vertexList, pNormal, pExtrusion, baseSubEntMarker);
229  releaseTraits(getInterface().conveyorContext());
230  }
231 
237  void shellProc(OdInt32 numVertices, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList,
238  const OdGiEdgeData* pEdgeData = 0, const OdGiFaceData* pFaceData = 0, const OdGiVertexData* pVertexData = 0)
239  {
240  setupTraits(getInterface().conveyorContext());
241  if (!isOutputOfClosedSectionsAsPolylinesEnabled())
242  getInterface().destinationGeometry().shellProc(numVertices, vertexList, faceListSize, faceList, pEdgeData, pFaceData, pVertexData);
243  else
244  shellProcAsPolylineProc(numVertices, vertexList, faceListSize, faceList, pEdgeData, pFaceData, pVertexData);
245  releaseTraits(getInterface().conveyorContext());
246  }
247  protected:
248  void shellProcAsPolylineProc(OdInt32 /*numVertices*/, const OdGePoint3d* vertexList, OdInt32 faceListSize, const OdInt32* faceList,
249  const OdGiEdgeData* /*pEdgeData*/, const OdGiFaceData* pFaceData, const OdGiVertexData* /*pVertexData*/)
250  {
251  OdInt32 nFace = 0, nFaceList = 0;
253  const bool bExtrusion = OdNonZero(getInterface().conveyorContext().subEntityTraits().thickness());
254  while (nFaceList < faceListSize)
255  {
256  const OdInt32 numVerts = Od_abs(faceList[nFaceList++]);
257  const OdGeVector3d *pNormal = (pFaceData && pFaceData->normals()) ? (pFaceData->normals() + nFace) : NULL;
258  if (pNormal && bExtrusion)
259  extrusion = *pNormal * getInterface().conveyorContext().subEntityTraits().thickness();
260  m_tmpPoints.resize(numVerts + 1);
261  OdGePoint3d *tmpPoints = m_tmpPoints.asArrayPtr();
262  for (OdInt32 nVert = 0; nVert < numVerts; nVert++)
263  tmpPoints[nVert] = vertexList[faceList[nFaceList++]];
264  tmpPoints[numVerts] = tmpPoints[0];
265  getInterface().destinationGeometry().polylineProc(numVerts + 1, tmpPoints, pNormal, (pNormal && bExtrusion) ? &extrusion : NULL);
266  nFace++;
267  }
268  }
269 };
270 
275 
276 #include "TD_PackPop.h"
277 
278 #endif //#ifndef __ODGISECTIONGEOMETRYOUTPUT_H__
OdGiSectionGeometryOutput::isOutputOfClosedSectionsAsPolylinesEnabled
bool isOutputOfClosedSectionsAsPolylinesEnabled() const
Definition: GiSectionGeometryOutput.h:116
GETBIT
#define GETBIT(flags, bit)
Definition: OdaDefs.h:498
OdGiEmptyGeometry
Definition: GiEmptyGeometry.h:42
OdGeVector3d
Definition: GeVector3d.h:54
NULL
#define NULL
Definition: GsProperties.h:177
OdGiSectionGeometryOutput::enableOutputOfClosedSectionsAsPolylines
void enableOutputOfClosedSectionsAsPolylines(bool bSet)
Definition: GiSectionGeometryOutput.h:121
OdGiSectionGeometryOutput::shellProcAsPolylineProc
void shellProcAsPolylineProc(OdInt32, const OdGePoint3d *vertexList, OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *, const OdGiFaceData *pFaceData, const OdGiVertexData *)
Definition: GiSectionGeometryOutput.h:248
OdGiSectionGeometryOutput::setInterface
void setInterface(SectionGeometryOutputInterface *pInterface)
Definition: GiSectionGeometryOutput.h:91
OdGiSectionGeometryOutput::sectionToleranceOverride
double sectionToleranceOverride() const
Definition: GiSectionGeometryOutput.h:131
OdGiSectionGeometryOutput::SectionGeometryOutputInterface
Definition: GiSectionGeometryOutput.h:47
SETBIT_1
#define SETBIT_1(flags, bit)
Definition: OdaDefs.h:501
OdRxObject
Definition: RxObject.h:564
OdGiSubEntityTraitsToDataWrapper::setTraits
void setTraits(TData &pTraits)
Definition: GiDummyGeometry.h:302
SETBIT
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:497
OdGiSectionGeometryOutput::setTraitsOverrideFlags
void setTraitsOverrideFlags(OdUInt32 nFlags)
Definition: GiSectionGeometryOutput.h:147
OdGiVertexData
Definition: GiGeometry.h:549
OdGiSectionGeometryOutput::getInterface
SectionGeometryOutputInterface & getInterface()
Definition: GiSectionGeometryOutput.h:84
OdArray< OdGePoint3d, OdMemoryAllocator< OdGePoint3d > >
TD_PackPop.h
OdGiSectionGeometryOutput::m_tolOverride
double m_tolOverride
Definition: GiSectionGeometryOutput.h:71
OdGiSectionGeometryOutput::traitsOverrideFlags
OdUInt32 traitsOverrideFlags() const
Definition: GiSectionGeometryOutput.h:154
OdGsMarker
ptrdiff_t OdGsMarker
Definition: OdPlatformSettings.h:889
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
OdGiFaceData::normals
const OdGeVector3d * normals() const
Definition: GiGeometry.h:459
ODGI_EXPORT
#define ODGI_EXPORT
Definition: GiExport.h:35
OdGiSectionGeometryOutput::setTraitsOverrides
void setTraitsOverrides(const OdGiSubEntityTraitsData &pData)
Definition: GiSectionGeometryOutput.h:163
OdGiSectionGeometryOutputPtr
OdSmartPtr< OdGiSectionGeometryOutput > OdGiSectionGeometryOutputPtr
Definition: GiSectionGeometryOutput.h:274
OdGiConveyorGeometry
Definition: GiConveyorGeometry.h:270
OdGiSectionGeometryOutput::traitsOverrides
OdGiSubEntityTraitsData & traitsOverrides()
Definition: GiSectionGeometryOutput.h:170
OdGiSectionGeometryOutput::m_tmpPoints
OdGePoint3dArray m_tmpPoints
Definition: GiSectionGeometryOutput.h:72
OdGiConveyorContext::onTraitsModified
virtual void onTraitsModified()=0
OdGiFaceData
Definition: GiGeometry.h:245
OdArray::asArrayPtr
const T * asArrayPtr() const
Definition: OdArray.h:1094
OdGiSectionGeometryOutput::createObject
static OdSmartPtr< OdGiSectionGeometryOutput > createObject()
Definition: GiSectionGeometryOutput.h:79
OdGiSectionGeometryOutput::traitsOverrides
const OdGiSubEntityTraitsData & traitsOverrides() const
Definition: GiSectionGeometryOutput.h:177
OdSmartPtr< OdGiSectionGeometryOutput >
OdGePoint3d
Definition: GePoint3d.h:55
SETBIT_0
#define SETBIT_0(flags, bit)
Definition: OdaDefs.h:500
OdInt32
int OdInt32
Definition: OdPlatformSettings.h:782
GiDummyGeometry.h
OdGiSubEntityTraitsData
Definition: GiSubEntityTraitsData.h:73
OdGiConveyorContext::subEntityTraits
virtual OdGiSubEntityTraits & subEntityTraits() const =0
OdGiSectionGeometryOutput::enableOpenedSectionsOutput
void enableOpenedSectionsOutput(bool bSet)
Definition: GiSectionGeometryOutput.h:111
OdArray::resize
void resize(size_type logicalLength, const T &value)
Definition: OdArray.h:834
OdGiSectionGeometryOutput::resetSectionToleranceOverride
void resetSectionToleranceOverride()
Definition: GiSectionGeometryOutput.h:141
OdGiSectionGeometryOutput::m_overrideFlags
OdUInt32 m_overrideFlags
Definition: GiSectionGeometryOutput.h:68
OdGiEdgeData
Definition: GiGeometry.h:67
OdGiSectionGeometryOutput::OdGiSectionGeometryOutput
OdGiSectionGeometryOutput()
Definition: GiSectionGeometryOutput.h:74
TD_PackPush.h
OdGiSectionGeometryOutput::setSectionToleranceOverride
void setSectionToleranceOverride(double tolOverride)
Definition: GiSectionGeometryOutput.h:136
OdRxObjectImpl::createObject
static OdSmartPtr< TInterface > createObject()
Definition: RxObjectImpl.h:107
OdGiSectionGeometryOutput::SectionGeometryOutputInterface::conveyorContext
virtual OdGiConveyorContext & conveyorContext()=0
OdGiConveyorContext
Definition: GiConveyorGeometry.h:54
OdGiSectionGeometryOutput::setupTraits
virtual void setupTraits(OdGiConveyorContext &context)
Definition: GiSectionGeometryOutput.h:188
OdGiSubEntityTraitsToData::copyTraits
static void copyTraits(OdGiSubEntityTraits &pFrom, OdGiSubEntityTraits &pTo, OdUInt32 nFlags=kAllChanged)
Definition: GiDummyGeometry.h:366
OdGiSectionGeometryOutput::m_flags
OdUInt32 m_flags
Definition: GiSectionGeometryOutput.h:67
OdGiSectionGeometryOutput::polylineProc
void polylineProc(OdInt32 numPoints, const OdGePoint3d *vertexList, const OdGeVector3d *pNormal=0, const OdGeVector3d *pExtrusion=0, OdGsMarker baseSubEntMarker=-1)
Definition: GiSectionGeometryOutput.h:224
FacetModeler::extrusion
FMGEOMETRY_API Body extrusion(const Profile2D &rBase, const OdGeMatrix3d &mBasePlane, const OdGeVector3d &vDir, const DeviationParams &devDeviation=FMGeGbl::gDefDev)
OdGiSectionGeometryOutput::isSectionToleranceOverrideEnabled
bool isSectionToleranceOverrideEnabled() const
Definition: GiSectionGeometryOutput.h:126
OdGiSectionGeometryOutput::Flags
Flags
Definition: GiSectionGeometryOutput.h:59
OdGiSectionGeometryOutput::m_overrides
OdGiSubEntityTraitsData m_overrides
Definition: GiSectionGeometryOutput.h:69
OdGiSectionGeometryOutput::enableClosedSectionsOutput
void enableClosedSectionsOutput(bool bSet)
Definition: GiSectionGeometryOutput.h:101
OdGiSectionGeometryOutput
Definition: GiSectionGeometryOutput.h:39
OdGiSectionGeometryOutput::m_pIface
SectionGeometryOutputInterface * m_pIface
Definition: GiSectionGeometryOutput.h:66
OdGiSectionGeometryOutput::SectionGeometryOutputInterface::destinationGeometry
virtual OdGiConveyorGeometry & destinationGeometry()=0
RxObjectImpl.h
OdGiSectionGeometryOutput::releaseTraits
virtual void releaseTraits(OdGiConveyorContext &context)
Definition: GiSectionGeometryOutput.h:208
OdGiSectionGeometryOutput::shellProc
void shellProc(OdInt32 numVertices, const OdGePoint3d *vertexList, OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData=0, const OdGiFaceData *pFaceData=0, const OdGiVertexData *pVertexData=0)
Definition: GiSectionGeometryOutput.h:237
OdGiSectionGeometryOutput::isOpenedSectionsOutputEnabled
bool isOpenedSectionsOutputEnabled() const
Definition: GiSectionGeometryOutput.h:106
OdGiSectionGeometryOutput::m_traits
OdGiSubEntityTraitsData m_traits
Definition: GiSectionGeometryOutput.h:70
OdGiSubEntityTraitsToData
Definition: GiDummyGeometry.h:361
OdNonZero
bool OdNonZero(double x, double tol=1.e-10)
Definition: OdaDefs.h:518
OdGiSectionGeometryOutput::isClosedSectionsOutputEnabled
bool isClosedSectionsOutputEnabled() const
Definition: GiSectionGeometryOutput.h:96
Od_abs
#define Od_abs
Definition: OdPlatform.h:130
GiEmptyGeometry.h