CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GiPointCloud.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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 __ODGIPOINTCLOUD_H__
25#define __ODGIPOINTCLOUD_H__
26
27#include "Gi/GiViewport.h"
28#include "Ge/GePoint3dArray.h"
29#include "Ge/GeVector3dArray.h"
30#include "Ge/GeMatrix3d.h"
31#include "Ge/GeBoundBlock3d.h"
32#include "UInt8Array.h"
33
34#include "TD_PackPush.h"
35
36#include "Gi/GiExport.h"
37
38// Forward declarations
43
50{
51 public:
53 {
54 kVertexComponent = 0, // Vertexes data component
55 kColorComponent, // Colors data component
56 kNormalComponent, // Normals data component
57 //
58 kNumComponents // Number of data components
59 };
61 { // Extra components (available in Components structure, but not in Flags)
62 kTransparencyComponent = kNumComponents,
63 kNumExtraComponents
64 };
66 { kNoComponents = 0, // No data components
67 kColors = (1 << 0), // Colors data component
68 kTransparencies = (1 << 1), // Transparencies data component
69 kNormals = (1 << 2) // Normals data component
70 };
72 {
73 kDataSizeByte = 0,
76 kDataSizeDouble
77 };
78 enum Flags
79 {
80 kLastComponentFlag = (1 << (kNumComponents << 1)), // Flags offset
81 // Flags
82 kAsyncCall = (kLastComponentFlag << 0), // Support asynchronic calls.
83 kPartialData = (kLastComponentFlag << 1), // Support partial data updates.
84 //
85 kLastFlag = kPartialData // Last flag
86 };
90 static OdUInt32 addDataSizeFlags(OdUInt32 *pFlags, Component component, DataSize ds)
91 { const OdUInt32 addSet = (OdUInt32)ds << (component << 1);
92 if (!pFlags) return addSet;
93 return *pFlags = (*pFlags & ~(3 << (component << 1))) | addSet;
94 }
99 {
100 return DataSize((flags >> (component << 1)) & 3);
101 }
109 }
111 {
112 OdUInt8Array m_component[kNumExtraComponents];
114 bool hasComponent(long nComponent) const { return !m_component[nComponent].isEmpty(); }
115 Components() : m_nPoints(0) {}
116 };
119 {
120 const void *m_pComponent[kNumExtraComponents];
122 bool hasComponent(long nComponent) const { return m_pComponent[nComponent] != NULL; }
123 ComponentsRaw &fromComponents(Components &comps, OdUInt32 components = 0xFFFFFFFF)
124 { const bool bNeedComponent[kNumExtraComponents] = /* Vertexes is always true */
125 { true, GETBIT(components, kColors), GETBIT(components, kNormals), GETBIT(components, kTransparencies) };
126 for (long nComponent = 0; nComponent < kNumExtraComponents; nComponent++)
127 m_pComponent[nComponent] = (bNeedComponent[nComponent] && comps.hasComponent(nComponent)) ?
128 comps.m_component[nComponent].getPtr() : NULL;
129 m_nPoints = comps.m_nPoints;
130 return *this; }
131 ComponentsRaw &construct(const void *pPoints, OdUInt32 nPoints, const void *pColors = NULL, const void *pTransparencies = NULL,
132 const void *pNormals = NULL)
133 { m_pComponent[kVertexComponent] = pPoints; m_pComponent[kColorComponent] = pColors;
134 m_pComponent[kTransparencyComponent] = pTransparencies; m_pComponent[kNormalComponent] = pNormals;
135 m_nPoints = nPoints;
136 return *this; }
137 };
139 public:
141
145 virtual OdUInt32 totalPointsCount() const = 0;
149 virtual OdUInt32 componentsMask() const { return kNoComponents; }
157 virtual OdUInt32 supportFlags(Component component = kNumComponents) const
158 { return (component == kNumComponents) ? 0 : ((component == kColorComponent) ? 2 : 8); }
159
163 virtual const OdGeMatrix3d &globalTransform() const { return OdGeMatrix3d::kIdentity; }
167 virtual OdInt32 defaultPointSize() const { return 0; }
168
172 virtual bool getExtents(OdGeBoundBlock3d & /*bb*/) const { return false; }
176 virtual bool calculateExtents(OdGeExtents3d &extents, const OdGiPointCloudFilter *pFilter = NULL) const;
177
181 virtual bool isDataCompatible(const OdGiViewport &pVp1, const OdGiViewport &pVp2) const = 0;
185 virtual bool updatePointsData(OdGiPointCloudReceiver *pReceiver, OdUInt32 components = kNoComponents,
186 OdUInt32 flags = 0, const OdGiViewport *pVp = NULL, const OdGiViewport *pVpFrom = NULL,
187 OdUInt32 pointSize = 0) const = 0;
188};
189
191
198{
199 protected:
201 public:
203
205 { m_pPrevFilter = pFilter; }
207 { OdGiPointCloudFilterPtr pFilter = m_pPrevFilter; m_pPrevFilter.release(); return pFilter; }
208 protected:
209 virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pArrays, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const = 0;
210 virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &bb) const = 0;
211 virtual void extractTransformImpl(OdGeMatrix3d & /*xForm*/) const { }
212 public:
213 bool filterPoints(OdGiPointCloud::ComponentsRaw *&pArrays, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const
214 { if (m_pPrevFilter.isNull() || m_pPrevFilter->filterPoints(pArrays, nArrays, compFlags, pExtents))
215 return filterPointsImpl(pArrays, nArrays, compFlags, pExtents);
216 return false;
217 }
219 { if (m_pPrevFilter.isNull() || m_pPrevFilter->filterBoundingBox(bb))
220 return filterBoundingBoxImpl(bb);
221 return false;
222 }
224 { if (!m_pPrevFilter.isNull())
225 { OdGeMatrix3d xForm = m_pPrevFilter->extractTransform();
226 extractTransformImpl(xForm);
227 return xForm;
228 } else {
229 OdGeMatrix3d xForm; extractTransformImpl(xForm); return xForm;
230 }
231 }
232};
233
240{
241 protected:
245 public:
247 protected:
248 virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pPoints, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const;
250 {
251 bb.transformBy(m_xForm);
252 return true;
253 }
254 virtual void extractTransformImpl(OdGeMatrix3d &xForm) const
255 { xForm.preMultBy(m_xForm); }
256 public:
257 void setXform(const OdGeMatrix3d &xForm) { m_xForm = xForm; }
258 void addXform(const OdGeMatrix3d &xForm) { m_xForm.preMultBy(xForm); }
259 const OdGeMatrix3d &getXform() const { return m_xForm; }
260 void resetXform() { m_xForm.setToIdentity(); }
261 bool hasXform() const { return m_xForm != OdGeMatrix3d::kIdentity; }
262 OdGeMatrix3d &accessXform() { return m_xForm; }
263
264 static OdGiPointCloudFilterPtr createObject(const OdGeMatrix3d &xForm, const OdGiPointCloudFilter *pPrevFilter = NULL);
265};
266
273{
274 protected:
277 public:
279 protected:
280 virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pPoints, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const;
281 virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &bb) const { return true; }
282 public:
283 void setComponentsRequest(OdUInt32 compFlags) { m_requestComps = compFlags; }
284 OdUInt32 componentsRequest() const { return m_requestComps; }
285
286 OdGiPointCloud::ComponentsArray &components() const { return m_comps; }
287
288 static OdGiPointCloudFilterPtr createObject(OdUInt32 compFlags, const OdGiPointCloudFilter *pPrevFilter = NULL);
289};
290
293
300{
301 protected:
304 public:
306
307 protected:
309 { m_pFilter = pFilter; }
311 { OdGiPointCloudFilterPtr pFilter = m_pFilter; m_pFilter.release(); return pFilter; }
312
314 { OdUInt32 nPoints = 0;
315 for (OdUInt32 nArray = 0; nArray < nArrays; nArray++)
316 nPoints += pArrays[nArray].m_nPoints;
317 return nPoints;
318 }
319
320 virtual bool addPointsImpl(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags,
321 OdGiPointCloudCellId nCellId, const OdGeBoundBlock3d *pExtents) = 0;
322 virtual bool removePointsImpl(OdUInt32 nPoints, OdGiPointCloudCellId nCellId) { return false; }
323 private:
324 bool addPointsFiltered(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags,
325 OdGiPointCloudCellId nCellId, const OdGeBoundBlock3d *pExtents)
327 OdGiPointCloud::ComponentsRaw *pCopy = NULL;
328 if (nArrays == 1) pointsCopy = *pArrays, pCopy = &pointsCopy;
329 else if (nArrays > 1) m_comps.resize(nArrays),
330 ::memcpy(m_comps.asArrayPtr(), pArrays, sizeof(OdGiPointCloud::ComponentsRaw) * nArrays), pCopy = m_comps.asArrayPtr();
331 if (m_pFilter->filterPoints(pCopy, nArrays, compFlags, pExtents))
332 return addPointsImpl(pCopy, nArrays, compFlags, nCellId, pExtents);
333 return true;
334 }
335 public:
336 bool addPoints(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags,
337 OdGiPointCloudCellId nCellId = kGiPointCloudNegativeCellId, const OdGeBoundBlock3d *pExtents = NULL)
338 {
339 if (!m_pFilter.isNull())
340 return addPointsFiltered(pArrays, nArrays, compFlags, nCellId, pExtents);
341 else
342 return addPointsImpl(pArrays, nArrays, compFlags, nCellId, pExtents);
343 }
345 {
346 return removePointsImpl(nPoints, nCellId);
347 }
348};
349
356{
357 protected:
359 public:
361
362 protected:
363 virtual bool addPointsImpl(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags,
364 OdGiPointCloudCellId /*nCellId*/, const OdGeBoundBlock3d *pExtents);
365 public:
367 { OdSmartPtr<OdGiPointCloudExtentsReceiver> pObj = createObject();
368 pObj->attachFilter(pFilter);
369 return pObj;
370 }
371
372 const OdGeExtents3d &getExtents() const { return m_extents; }
373 void resetExtents() { m_extents = OdGeExtents3d::kInvalid; }
374};
375
376#include "TD_PackPop.h"
377
378#endif // __ODGIPOINTCLOUD_H__
#define ODGI_EXPORT
Definition: GiExport.h:35
const OdGiPointCloudCellId kGiPointCloudNegativeCellId
Definition: GiPointCloud.h:292
OdSmartPtr< OdGiPointCloudFilter > OdGiPointCloudFilterPtr
Definition: GiPointCloud.h:40
OdSmartPtr< OdGiPointCloudReceiver > OdGiPointCloudReceiverPtr
Definition: GiPointCloud.h:42
OdSmartPtr< OdGiPointCloud > OdGiPointCloudPtr
Definition: GiPointCloud.h:190
OdUInt64 OdGiPointCloudCellId
Definition: GiPointCloud.h:291
unsigned int OdUInt32
int OdInt32
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
const T * asArrayPtr() const
Definition: OdArray.h:1590
bool isEmpty() const
Definition: OdArray.h:1547
const T * getPtr() const
Definition: OdArray.h:1600
void resize(size_type logicalLength, const T &value)
Definition: OdArray.h:1185
bool isNull() const
Definition: BaseObjectPtr.h:86
OdGeEntity3d & transformBy(const OdGeMatrix3d &xfm)
static GE_STATIC_EXPORT const OdGeExtents3d kInvalid
Definition: GeExtents3d.h:65
OdGeMatrix3d & setToIdentity()
static GE_STATIC_EXPORT const OdGeMatrix3d kIdentity
Definition: GeMatrix3d.h:97
OdGeMatrix3d & preMultBy(const OdGeMatrix3d &leftSide)
OdGiPointCloud::ComponentsArray m_comps
Definition: GiPointCloud.h:275
virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pPoints, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const
OdGiPointCloud::ComponentsArray & components() const
Definition: GiPointCloud.h:286
static OdGiPointCloudFilterPtr createObject(OdUInt32 compFlags, const OdGiPointCloudFilter *pPrevFilter=NULL)
void setComponentsRequest(OdUInt32 compFlags)
Definition: GiPointCloud.h:283
virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &bb) const
Definition: GiPointCloud.h:281
ODRX_DECLARE_MEMBERS(OdGiPointCloudComponentsFilter)
OdUInt32 componentsRequest() const
Definition: GiPointCloud.h:284
const OdGeExtents3d & getExtents() const
Definition: GiPointCloud.h:372
static OdGiPointCloudReceiverPtr createObject(const OdGiPointCloudFilter *pFilter)
Definition: GiPointCloud.h:366
virtual bool addPointsImpl(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags, OdGiPointCloudCellId, const OdGeBoundBlock3d *pExtents)
ODRX_DECLARE_MEMBERS(OdGiPointCloudExtentsReceiver)
virtual void extractTransformImpl(OdGeMatrix3d &) const
Definition: GiPointCloud.h:211
void attachFilter(const OdGiPointCloudFilter *pFilter)
Definition: GiPointCloud.h:204
OdGiPointCloudFilterPtr m_pPrevFilter
Definition: GiPointCloud.h:200
ODRX_DECLARE_MEMBERS(OdGiPointCloudFilter)
virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &bb) const =0
OdGiPointCloudFilterPtr detachFilter()
Definition: GiPointCloud.h:206
virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pArrays, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const =0
bool filterPoints(OdGiPointCloud::ComponentsRaw *&pArrays, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const
Definition: GiPointCloud.h:213
bool filterBoundingBox(OdGeBoundBlock3d &bb) const
Definition: GiPointCloud.h:218
OdGeMatrix3d extractTransform() const
Definition: GiPointCloud.h:223
virtual OdUInt32 componentsMask() const
Definition: GiPointCloud.h:149
virtual bool updatePointsData(OdGiPointCloudReceiver *pReceiver, OdUInt32 components=kNoComponents, OdUInt32 flags=0, const OdGiViewport *pVp=NULL, const OdGiViewport *pVpFrom=NULL, OdUInt32 pointSize=0) const =0
ODRX_DECLARE_MEMBERS(OdGiPointCloud)
virtual bool getExtents(OdGeBoundBlock3d &) const
Definition: GiPointCloud.h:172
virtual const OdGeMatrix3d & globalTransform() const
Definition: GiPointCloud.h:163
static OdUInt32 getDefaultDataSizeFlags()
Definition: GiPointCloud.h:105
virtual bool isDataCompatible(const OdGiViewport &pVp1, const OdGiViewport &pVp2) const =0
virtual bool calculateExtents(OdGeExtents3d &extents, const OdGiPointCloudFilter *pFilter=NULL) const
OdArray< Components > ComponentsArray
Definition: GiPointCloud.h:117
static DataSize getDataSizeFlags(OdUInt32 flags, Component component)
Definition: GiPointCloud.h:98
virtual OdInt32 defaultPointSize() const
Definition: GiPointCloud.h:167
static OdUInt32 addDataSizeFlags(OdUInt32 *pFlags, Component component, DataSize ds)
Definition: GiPointCloud.h:90
virtual OdUInt32 supportFlags(Component component=kNumComponents) const
Definition: GiPointCloud.h:157
OdArray< ComponentsRaw, OdMemoryAllocator< ComponentsRaw > > ComponentsRawArray
Definition: GiPointCloud.h:138
virtual OdUInt32 totalPointsCount() const =0
OdGiPointCloudFilterPtr detachFilter()
Definition: GiPointCloud.h:310
OdGiPointCloud::ComponentsRawArray m_comps
Definition: GiPointCloud.h:303
OdGiPointCloudFilterPtr m_pFilter
Definition: GiPointCloud.h:302
OdUInt32 numPointsTotal(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays) const
Definition: GiPointCloud.h:313
bool removePoints(OdUInt32 nPoints, OdGiPointCloudCellId nCellId=kGiPointCloudNegativeCellId)
Definition: GiPointCloud.h:344
virtual bool addPointsImpl(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags, OdGiPointCloudCellId nCellId, const OdGeBoundBlock3d *pExtents)=0
ODRX_DECLARE_MEMBERS(OdGiPointCloudReceiver)
bool addPoints(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags, OdGiPointCloudCellId nCellId=kGiPointCloudNegativeCellId, const OdGeBoundBlock3d *pExtents=NULL)
Definition: GiPointCloud.h:336
virtual bool removePointsImpl(OdUInt32 nPoints, OdGiPointCloudCellId nCellId)
Definition: GiPointCloud.h:322
void attachFilter(const OdGiPointCloudFilter *pFilter)
Definition: GiPointCloud.h:308
OdGeBoundBlock3d m_bb
Definition: GiPointCloud.h:243
OdGiPointCloud::ComponentsArray m_comps
Definition: GiPointCloud.h:242
virtual void extractTransformImpl(OdGeMatrix3d &xForm) const
Definition: GiPointCloud.h:254
ODRX_DECLARE_MEMBERS(OdGiPointCloudXformFilter)
virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pPoints, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const
OdGeMatrix3d & accessXform()
Definition: GiPointCloud.h:262
const OdGeMatrix3d & getXform() const
Definition: GiPointCloud.h:259
void setXform(const OdGeMatrix3d &xForm)
Definition: GiPointCloud.h:257
virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &bb) const
Definition: GiPointCloud.h:249
static OdGiPointCloudFilterPtr createObject(const OdGeMatrix3d &xForm, const OdGiPointCloudFilter *pPrevFilter=NULL)
void addXform(const OdGeMatrix3d &xForm)
Definition: GiPointCloud.h:258
void release()
Definition: SmartPtr.h:269
OdUInt8Array m_component[kNumExtraComponents]
Definition: GiPointCloud.h:112
bool hasComponent(long nComponent) const
Definition: GiPointCloud.h:114
bool hasComponent(long nComponent) const
Definition: GiPointCloud.h:122
ComponentsRaw & construct(const void *pPoints, OdUInt32 nPoints, const void *pColors=NULL, const void *pTransparencies=NULL, const void *pNormals=NULL)
Definition: GiPointCloud.h:131
ComponentsRaw & fromComponents(Components &comps, OdUInt32 components=0xFFFFFFFF)
Definition: GiPointCloud.h:123