CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GiPointCloud.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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
39
51class OdPerfTimerBase;
52
58class ODGI_EXPORT OdGiPointCloud : public OdRxObject
59{
60 public:
62 {
63 kVertexComponent = 0, // Vertexes data component
64 kColorComponent, // Colors data component
65 kNormalComponent, // Normals data component
66 //
67 kNumComponents // Number of data components
68 };
70 { // Extra components (available in Components structure, but not in Flags)
73 };
75 { kNoComponents = 0, // No data components
76 kColors = (1 << 0), // Colors data component
77 kTransparencies = (1 << 1), // Transparencies data component
78 kNormals = (1 << 2) // Normals data component
79 };
87 enum Flags
88 {
89 kLastComponentFlag = (1 << (kNumComponents << 1)), // Flags offset
90 // Flags
91 kAsyncCall = (kLastComponentFlag << 0), // Support asynchronic calls.
92 kPartialData = (kLastComponentFlag << 1), // Support partial data updates.
93 //
94 kLastFlag = kPartialData // Last flag
95 };
96
99 static OdUInt32 addDataSizeFlags(OdUInt32 *pFlags, Component component, DataSize ds)
100 { const OdUInt32 addSet = (OdUInt32)ds << (component << 1);
101 if (!pFlags) return addSet;
102 return *pFlags = (*pFlags & ~(3 << (component << 1))) | addSet;
103 }
104
108 {
109 return DataSize((flags >> (component << 1)) & 3);
110 }
111
120 {
123 bool hasComponent(long nComponent) const { return !m_component[nComponent].isEmpty(); }
125 };
128 {
131 bool hasComponent(long nComponent) const { return m_pComponent[nComponent] != NULL; }
132 ComponentsRaw &fromComponents(Components &comps, OdUInt32 components = 0xFFFFFFFF)
133 { const bool bNeedComponent[kNumExtraComponents] = /* Vertexes is always true */
134 { true, GETBIT(components, kColors), GETBIT(components, kNormals), GETBIT(components, kTransparencies) };
135 for (long nComponent = 0; nComponent < kNumExtraComponents; nComponent++)
136 m_pComponent[nComponent] = (bNeedComponent[nComponent] && comps.hasComponent(nComponent)) ?
137 comps.m_component[nComponent].getPtr() : NULL;
138 m_nPoints = comps.m_nPoints;
139 return *this; }
140 ComponentsRaw &construct(const void *pPoints, OdUInt32 nPoints, const void *pColors = NULL, const void *pTransparencies = NULL,
141 const void *pNormals = NULL)
144 m_nPoints = nPoints;
145 return *this; }
146 };
148 public:
150
154 virtual OdUInt32 totalPointsCount() const = 0;
158 virtual OdUInt32 componentsMask() const { return kNoComponents; }
167 { return (component == kNumComponents) ? 0 : ((component == kColorComponent) ? 2 : 8); }
168
172 virtual const OdGeMatrix3d &globalTransform() const { return OdGeMatrix3d::kIdentity; }
176 virtual OdInt32 defaultPointSize() const { return 0; }
177
181 virtual bool getExtents(OdGeBoundBlock3d & /*bb*/) const { return false; }
185 virtual bool calculateExtents(OdGeExtents3d &extents, const OdGiPointCloudFilter *pFilter = NULL) const;
186
190 virtual bool isDataCompatible(const OdGiViewport &pVp1, const OdGiViewport &pVp2) const = 0;
194 virtual bool updatePointsData(OdGiPointCloudReceiver *pReceiver, OdUInt32 components = kNoComponents,
195 OdUInt32 flags = 0, const OdGiViewport *pVp = NULL, const OdGiViewport *pVpFrom = NULL,
196 OdUInt32 pointSize = 0, OdGiPointCloudScheduler *pExternalScheduler = NULL) const = 0;
197};
198
203
209class ODGI_EXPORT OdGiPointCloudFilter : public OdRxObject
210{
211 protected:
213 public:
215
217 { m_pPrevFilter = pFilter; }
220 protected:
221 virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pArrays, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const = 0;
222 virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &bb) const = 0;
223 virtual void extractTransformImpl(OdGeMatrix3d & /*xForm*/) const { }
224 public:
225 bool filterPoints(OdGiPointCloud::ComponentsRaw *&pArrays, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const
226 { if (m_pPrevFilter.isNull() || m_pPrevFilter->filterPoints(pArrays, nArrays, compFlags, pExtents))
227 return filterPointsImpl(pArrays, nArrays, compFlags, pExtents);
228 return false;
229 }
231 { if (m_pPrevFilter.isNull() || m_pPrevFilter->filterBoundingBox(bb))
232 return filterBoundingBoxImpl(bb);
233 return false;
234 }
236 { if (!m_pPrevFilter.isNull())
237 { OdGeMatrix3d xForm = m_pPrevFilter->extractTransform();
239 return xForm;
240 } else {
241 OdGeMatrix3d xForm; extractTransformImpl(xForm); return xForm;
242 }
243 }
245 {
246 return m_pPrevFilter;
247 }
248};
249
256{
257 protected:
261 public:
263
268
273 protected:
274 virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pPoints, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const;
276 {
278 return true;
279 }
280 virtual void extractTransformImpl(OdGeMatrix3d &xForm) const
281 { xForm.preMultBy(m_xForm); }
282 public:
288 void setXform(const OdGeMatrix3d &xForm) { m_xForm = xForm; }
289
295 void addXform(const OdGeMatrix3d &xForm) { m_xForm.preMultBy(xForm); }
296
303 const OdGeMatrix3d &getXform() const { return m_xForm; }
304
308 void resetXform() { m_xForm.setToIdentity(); }
309
316 bool hasXform() const { return m_xForm != OdGeMatrix3d::kIdentity; }
317
325
334 static OdGiPointCloudFilterPtr createObject(const OdGeMatrix3d &xForm, const OdGiPointCloudFilter *pPrevFilter = NULL);
335};
336
343{
344 protected:
347 public:
349 protected:
350 virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pPoints, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const;
351 virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &) const { return true; }
352 public:
353 void setComponentsRequest(OdUInt32 compFlags) { m_requestComps = compFlags; }
355
357
358 static OdGiPointCloudFilterPtr createObject(OdUInt32 compFlags, const OdGiPointCloudFilter *pPrevFilter = NULL);
359};
360
367{
368 public:
369 // ODRX_DECLARE_MEMBERS(OdGiPointCloudComponentsFilter); // No need own RTTI
370 protected:
371 virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *& /*pPoints*/, OdUInt32 & /*nArrays*/, OdUInt32 & /*compFlags*/,
372 const OdGeBoundBlock3d *& /*pExtents*/) const { return true; }
373 virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d & /*bb*/) const { return true; }
374 public:
375 static OdGiPointCloudFilterPtr createObject(const OdGiPointCloudFilter *pPrevFilter = NULL, bool bForce = false);
376};
377
380
387{
388 protected:
391 public:
393
394 protected:
396 { m_pFilter = pFilter; }
398 { OdGiPointCloudFilterPtr pFilter = m_pFilter; m_pFilter.release(); return pFilter; }
399
401 { OdUInt32 nPoints = 0;
402 for (OdUInt32 nArray = 0; nArray < nArrays; nArray++)
403 nPoints += pArrays[nArray].m_nPoints;
404 return nPoints;
405 }
406
407 virtual bool addPointsImpl(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags,
408 OdGiPointCloudCellId nCellId, const OdGeBoundBlock3d *pExtents) = 0;
409 virtual bool removePointsImpl(OdUInt32 /*nPoints*/, OdGiPointCloudCellId /*nCellId*/) { return false; }
410 private:
411 bool addPointsFiltered(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags,
412 OdGiPointCloudCellId nCellId, const OdGeBoundBlock3d *pExtents)
414 OdGiPointCloud::ComponentsRaw *pCopy = NULL;
415 if (nArrays == 1) pointsCopy = *pArrays, pCopy = &pointsCopy;
416 else if (nArrays > 1) m_comps.resize(nArrays),
417 ::memcpy(m_comps.asArrayPtr(), pArrays, sizeof(OdGiPointCloud::ComponentsRaw) * nArrays), pCopy = m_comps.asArrayPtr();
418 if (m_pFilter->filterPoints(pCopy, nArrays, compFlags, pExtents))
419 return addPointsImpl(pCopy, nArrays, compFlags, nCellId, pExtents);
420 return true;
421 }
422 public:
423 bool addPoints(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags,
424 OdGiPointCloudCellId nCellId = kGiPointCloudNegativeCellId, const OdGeBoundBlock3d *pExtents = NULL)
425 {
426 if (!m_pFilter.isNull())
427 return addPointsFiltered(pArrays, nArrays, compFlags, nCellId, pExtents);
428 else
429 return addPointsImpl(pArrays, nArrays, compFlags, nCellId, pExtents);
430 }
432 {
433 return removePointsImpl(nPoints, nCellId);
434 }
435};
436
443{
444 protected:
446 public:
448
449 protected:
450 virtual bool addPointsImpl(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags,
451 OdGiPointCloudCellId /*nCellId*/, const OdGeBoundBlock3d *pExtents);
452 public:
455 pObj->attachFilter(pFilter);
456 return pObj;
457 }
458
459 const OdGeExtents3d &getExtents() const { return m_extents; }
461};
462
469{
470 public:
472 {
473 kDisabled = 0, // Scheduler disabled
474 kProcessing, // Scheduler enabled, data processing in progress.
475 kStopped // Scheduler requests abort of data processing.
476 };
477 protected:
479 public:
484
489
493 virtual void startScheduling() = 0;
497 virtual void stopScheduling() = 0;
498
502 virtual SchedulerState checkSchedulerState(bool bFinal = false) = 0;
503
507 bool onTaskAdded() { return (++m_numTasks) == 1; }
511 bool onTaskCompleted() { return !(--m_numTasks); }
515 int numTasks() const { return m_numTasks; }
516};
517
563
564#include "TD_PackPop.h"
565
566#endif // __ODGIPOINTCLOUD_H__
#define ODGI_EXPORT
Definition GiExport.h:35
const OdGiPointCloudCellId kGiPointCloudNegativeCellId
OdSmartPtr< OdGiPointCloudFilter > OdGiPointCloudFilterPtr
OdSmartPtr< OdGiPointCloudReceiver > OdGiPointCloudReceiverPtr
OdSmartPtr< OdGiPointCloud > OdGiPointCloudPtr
OdUInt64 OdGiPointCloudCellId
int OdRefCounter
Definition OdMutex.h:478
unsigned int OdUInt32
int OdInt32
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
#define FIRSTDLL_EXPORT
Definition RootExport.h:39
OdArray< OdUInt8, OdMemoryAllocator< OdUInt8 > > OdUInt8Array
Definition UInt8Array.h:35
const T * asArrayPtr() const
Definition OdArray.h:1612
const T * getPtr() const
Definition OdArray.h:1622
void resize(size_type logicalLength, const T &value)
Definition OdArray.h:1192
OdGeEntity3d & transformBy(const OdGeMatrix3d &xfm)
static GE_STATIC_EXPORT const OdGeExtents3d kInvalid
Definition GeExtents3d.h:65
static GE_STATIC_EXPORT const OdGeMatrix3d kIdentity
Definition GeMatrix3d.h:97
OdGeMatrix3d & preMultBy(const OdGeMatrix3d &leftSide)
OdGiPointCloud::ComponentsArray m_comps
virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pPoints, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const
OdGiPointCloud::ComponentsArray & components() const
static OdGiPointCloudFilterPtr createObject(OdUInt32 compFlags, const OdGiPointCloudFilter *pPrevFilter=NULL)
void setComponentsRequest(OdUInt32 compFlags)
ODRX_DECLARE_MEMBERS(OdGiPointCloudComponentsFilter)
virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &) const
OdUInt32 componentsRequest() const
const OdGeExtents3d & getExtents() const
static OdGiPointCloudReceiverPtr createObject(const OdGiPointCloudFilter *pFilter)
virtual bool addPointsImpl(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags, OdGiPointCloudCellId, const OdGeBoundBlock3d *pExtents)
ODRX_DECLARE_MEMBERS(OdGiPointCloudExtentsReceiver)
virtual void extractTransformImpl(OdGeMatrix3d &) const
void attachFilter(const OdGiPointCloudFilter *pFilter)
OdGiPointCloudFilterPtr m_pPrevFilter
ODRX_DECLARE_MEMBERS(OdGiPointCloudFilter)
virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &bb) const =0
OdGiPointCloudFilterPtr detachFilter()
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
bool filterBoundingBox(OdGeBoundBlock3d &bb) const
OdGeMatrix3d extractTransform() const
const OdGiPointCloudFilter * previousFilter() const
virtual bool updatePointsData(OdGiPointCloudReceiver *pReceiver, OdUInt32 components=kNoComponents, OdUInt32 flags=0, const OdGiViewport *pVp=NULL, const OdGiViewport *pVpFrom=NULL, OdUInt32 pointSize=0, OdGiPointCloudScheduler *pExternalScheduler=NULL) const =0
virtual OdUInt32 componentsMask() const
ODRX_DECLARE_MEMBERS(OdGiPointCloud)
virtual bool getExtents(OdGeBoundBlock3d &) const
virtual const OdGeMatrix3d & globalTransform() const
static OdUInt32 getDefaultDataSizeFlags()
virtual bool isDataCompatible(const OdGiViewport &pVp1, const OdGiViewport &pVp2) const =0
virtual bool calculateExtents(OdGeExtents3d &extents, const OdGiPointCloudFilter *pFilter=NULL) const
OdArray< Components > ComponentsArray
static DataSize getDataSizeFlags(OdUInt32 flags, Component component)
virtual OdInt32 defaultPointSize() const
static OdUInt32 addDataSizeFlags(OdUInt32 *pFlags, Component component, DataSize ds)
virtual OdUInt32 supportFlags(Component component=kNumComponents) const
OdArray< ComponentsRaw, OdMemoryAllocator< ComponentsRaw > > ComponentsRawArray
virtual OdUInt32 totalPointsCount() const =0
static OdGiPointCloudFilterPtr createObject(const OdGiPointCloudFilter *pPrevFilter=NULL, bool bForce=false)
virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&, OdUInt32 &, OdUInt32 &, const OdGeBoundBlock3d *&) const
virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &) const
OdGiPointCloudFilterPtr detachFilter()
OdGiPointCloud::ComponentsRawArray m_comps
OdGiPointCloudFilterPtr m_pFilter
OdUInt32 numPointsTotal(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays) const
bool removePoints(OdUInt32 nPoints, OdGiPointCloudCellId nCellId=kGiPointCloudNegativeCellId)
virtual bool addPointsImpl(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags, OdGiPointCloudCellId nCellId, const OdGeBoundBlock3d *pExtents)=0
virtual bool removePointsImpl(OdUInt32, OdGiPointCloudCellId)
ODRX_DECLARE_MEMBERS(OdGiPointCloudReceiver)
bool addPoints(const OdGiPointCloud::ComponentsRaw *pArrays, OdUInt32 nArrays, OdUInt32 compFlags, OdGiPointCloudCellId nCellId=kGiPointCloudNegativeCellId, const OdGeBoundBlock3d *pExtents=NULL)
void attachFilter(const OdGiPointCloudFilter *pFilter)
virtual void startScheduling()=0
virtual void stopScheduling()=0
virtual SchedulerState checkSchedulerState(bool bFinal=false)=0
virtual ~OdGiPointCloudScheduler()
void setTimerPeriod(OdUInt32 msec)
SchedulerState checkSchedulerState(bool bFinal=false)
OdGiPointCloud::ComponentsArray m_comps
virtual void extractTransformImpl(OdGeMatrix3d &xForm) const
ODRX_DECLARE_MEMBERS(OdGiPointCloudXformFilter)
virtual bool filterPointsImpl(OdGiPointCloud::ComponentsRaw *&pPoints, OdUInt32 &nArrays, OdUInt32 &compFlags, const OdGeBoundBlock3d *&pExtents) const
OdGeMatrix3d & accessXform()
const OdGeMatrix3d & getXform() const
OdGeBoundBlock3d * m_pBB
void setXform(const OdGeMatrix3d &xForm)
virtual bool filterBoundingBoxImpl(OdGeBoundBlock3d &bb) const
static OdGiPointCloudFilterPtr createObject(const OdGeMatrix3d &xForm, const OdGiPointCloudFilter *pPrevFilter=NULL)
void addXform(const OdGeMatrix3d &xForm)
OdUInt8Array m_component[kNumExtraComponents]
bool hasComponent(long nComponent) const
bool hasComponent(long nComponent) const
const void * m_pComponent[kNumExtraComponents]
ComponentsRaw & construct(const void *pPoints, OdUInt32 nPoints, const void *pColors=NULL, const void *pTransparencies=NULL, const void *pNormals=NULL)
ComponentsRaw & fromComponents(Components &comps, OdUInt32 components=0xFFFFFFFF)