CFx SDK Documentation  2023 SP0
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__
#define ODGI_EXPORT
Definition: GiExport.h:35
OdSmartPtr< OdGiSectionGeometryOutput > OdGiSectionGeometryOutputPtr
#define NULL
Definition: GsProperties.h:177
#define Od_abs
Definition: OdPlatform.h:130
ptrdiff_t OdGsMarker
unsigned int OdUInt32
int OdInt32
bool OdNonZero(double x, double tol=1.e-10)
Definition: OdaDefs.h:520
#define SETBIT(flags, bit, value)
Definition: OdaDefs.h:499
#define SETBIT_0(flags, bit)
Definition: OdaDefs.h:502
#define GETBIT(flags, bit)
Definition: OdaDefs.h:500
#define SETBIT_1(flags, bit)
Definition: OdaDefs.h:503
const T * asArrayPtr() const
Definition: OdArray.h:1094
void resize(size_type logicalLength, const T &value)
Definition: OdArray.h:834
virtual OdGiSubEntityTraits & subEntityTraits() const =0
virtual void onTraitsModified()=0
const OdGeVector3d * normals() const
Definition: GiGeometry.h:459
SectionGeometryOutputInterface * m_pIface
void setTraitsOverrideFlags(OdUInt32 nFlags)
virtual void releaseTraits(OdGiConveyorContext &context)
void polylineProc(OdInt32 numPoints, const OdGePoint3d *vertexList, const OdGeVector3d *pNormal=0, const OdGeVector3d *pExtrusion=0, OdGsMarker baseSubEntMarker=-1)
OdGiSubEntityTraitsData m_overrides
OdGiSubEntityTraitsData m_traits
bool isOutputOfClosedSectionsAsPolylinesEnabled() const
static OdSmartPtr< OdGiSectionGeometryOutput > createObject()
void setInterface(SectionGeometryOutputInterface *pInterface)
void setTraitsOverrides(const OdGiSubEntityTraitsData &pData)
const OdGiSubEntityTraitsData & traitsOverrides() const
void setSectionToleranceOverride(double tolOverride)
SectionGeometryOutputInterface & getInterface()
OdGiSubEntityTraitsData & traitsOverrides()
virtual void setupTraits(OdGiConveyorContext &context)
void enableOutputOfClosedSectionsAsPolylines(bool bSet)
void shellProc(OdInt32 numVertices, const OdGePoint3d *vertexList, OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *pEdgeData=0, const OdGiFaceData *pFaceData=0, const OdGiVertexData *pVertexData=0)
void shellProcAsPolylineProc(OdInt32, const OdGePoint3d *vertexList, OdInt32 faceListSize, const OdInt32 *faceList, const OdGiEdgeData *, const OdGiFaceData *pFaceData, const OdGiVertexData *)
static void copyTraits(OdGiSubEntityTraits &pFrom, OdGiSubEntityTraits &pTo, OdUInt32 nFlags=kAllChanged)
static OdSmartPtr< TInterface > createObject()
Definition: RxObjectImpl.h:107
AECGEOMETRY_API FacetModeler::Body extrusion(const FacetModeler::Profile2D &rBase, const FacetModeler::Contour3D &rPath, const FacetModeler::DeviationParams &devDeviation=FacetModeler::FMGeGbl::gDefDev)
virtual OdGiConveyorGeometry & destinationGeometry()=0