CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GiProgressiveMesh.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#ifndef ODGI_PROGRESSIVEMESH_H_INCLUDED
24#define ODGI_PROGRESSIVEMESH_H_INCLUDED
25
26#include "OdStreamBuf.h"
27#include "OdVector.h"
28#include "Ge/GeExtents3d.h"
29#include "GiGeometry.h"
30class OdGiViewport;
32
37{
38public:
45 virtual bool registerDataBegin( OdUInt8 dataId, OdUInt64 localOffset ) = 0;
52 virtual bool registerDataEnd( OdUInt8 dataId, OdUInt64 localOffset ) = 0;
57 virtual OdUInt64 tell() = 0;
63 virtual bool beginExtraction( OdUInt8 dataId ) = 0;
69 virtual bool endExtraction( OdUInt8 dataId ) = 0;
75 virtual bool seekFromLocalOffset( OdUInt64 offset ) = 0;
81 virtual void extractBytes( void* buffer, OdUInt32 numBytes ) = 0;
87 virtual double extractDouble();
117 virtual bool extractBool();
118};
119
146
173
192
199{
200public:
204 virtual OdInt64 dbStubToInt( OdDbStub* ) const = 0;
208 virtual OdDbStub* intToDbStub( OdInt64 ) const = 0;
209};
210
215{
216public:
226 virtual OdUInt32 selectLOD( const OdGiProgressiveMesh* pPM, const OdGiViewport* pView, const OdGeMatrix3d* pModelToWorldTransform ) const = 0;
227};
228
233{
234public:
239 {
240 m_nMinPixels = 10;
241 m_nMaxPixels = (OdUInt32)( 300.0 * sqrt( 3.0 ) );
242 }
243
251 OdUInt32 maxPixels() const { return m_nMaxPixels; }
256 void setMaxPixels( OdUInt32 nMax ) { m_nMaxPixels = nMax; }
261 OdUInt32 minPixels() const { return m_nMinPixels; }
266 void setMinPixels( OdUInt32 nMin ) { m_nMinPixels = nMin; }
267//DOM-IGNORE-BEGIN
268protected:
271//DOM-IGNORE-END
272};
273
279class ODGI_EXPORT OdGiProgressiveMesh : public OdRxObject
280{
281public:
294
298 {
299 kCustom = 0, //Custom LOD select by callback
300 kSqrInterpolation = 1, //Square interpolation LOD select
301 kSqrtInterpolation = 2 //Square root interpolation LOD select
302 };
311 virtual bool obtainShell( OdVector< OdGePoint3d >& pts, OdVector< OdInt32 >& faces ) const = 0;
339 virtual OdUInt32 numLODs() const = 0;
345 virtual OdUInt32 currentLOD() const = 0;
349 virtual bool setLOD( OdUInt32 ) = 0;
357 virtual OdUInt32 selectLOD( ProgressiveMeshAutoSelectLOD lod, const OdGiViewport* pView, const OdGeMatrix3d* pModelToWorldTransform = NULL ) = 0;
386 virtual OdUInt32 numFaces() const = 0;
390 virtual OdUInt32 numVertices() const = 0;
394 virtual const OdGeExtents3d& extents() const = 0;
401 virtual bool write( OdStreamBuf* pBuff, const OdGiProgressiveMeshObjectIdConverter* pConverter = NULL, ProgressiveMeshStreamVersion version = kVersionActual ) const = 0;
406 virtual bool isInPartialMode() const = 0;
410 virtual void endPartialMode() = 0;
415 virtual OdUInt64 getObjectSize() const = 0;
416};
417
422
432{
433public:
438
443
447 OdUInt32 minVertices() const { return m_minVertices; }
453 void setMinVertices( OdUInt32 n ) { m_minVertices = n; }
457 OdUInt32 minFaces() const { return m_minFaces; }
463 void setMinFaces( OdUInt32 n ) { m_minFaces = n; }
467 double worstDiherial() const { return m_worstDiherial; }
474 void setWorstDiherial( double d ) { m_worstDiherial = d; }
478 double smallestCost() const { return m_minCost; }
485 void setSmallestCost( double d ) { m_minCost = d; }
489 double worstCost() const { return m_worstCost; }
496 void setWorstCost( double d ) { m_worstCost = d; }
500 double infinity() const { return m_infinity; }
507 void setInfinity( double d ) { m_infinity = d; }
511 bool getFitNormals() const { return GETBIT( m_flags, kFlag_FitNormals ); }
515 double normalErrorFactor() const { return m_normalErrorFactor; }
523 void setFitNormals( bool bFit, double errorFactor )
524 {
525 SETBIT( m_flags, kFlag_FitNormals, bFit );
526 m_normalErrorFactor = errorFactor;
527 }
528
531 bool getFitColors() const { return GETBIT( m_flags, kFlag_FitColors ); }
535 double colorErrorFactor() const { return m_colorErrorFactor; }
543 void setFitColors( bool bFit, double errorFactor )
544 {
545 SETBIT( m_flags, kFlag_FitColors, bFit );
546 m_colorErrorFactor = errorFactor;
547 }
548
551 double sharpEdgesScaleFactor() const { return m_sharpEdgesScaleFactor; }
557 void setSharpEdgesScaleFactor( double d ) { m_sharpEdgesScaleFactor = d; }
558
562 double nextCostThresholdFactor() const { return m_nextCostThresholdFactor; }
570 void setNextCostThresholdFactor( double d ) { m_nextCostThresholdFactor = d; }
571
575 bool getDiffMaxPenalty() const { return GETBIT( m_flags, kFlag_DesH ); }
579 double diffMaxPenaltyFactor() const { return m_desdFactor; }
588 void setDiffMaxPenalty( bool bSet, double factor )
589 {
590 SETBIT( m_flags, kFlag_DesH, bSet );
591 m_desdFactor = factor;
592 }
593
596 bool getSumPenalty() const { return GETBIT( m_flags, kFlag_DesN ); }
600 double sumPenaltyFactor() const { return m_desnFactor; }
609 void setSumPenalty( bool bSet, double factor )
610 {
611 SETBIT( m_flags, kFlag_DesN, bSet );
612 m_desnFactor = factor;
613 }
614
617 OdUInt8 strictSharp() const { return m_strictSharp; }
618 //Unsupported for now
619 /*void setStrictSharp( OdUInt8 val )
620 {
621 ODA_ASSERT( val < 3 );
622 m_strictSharp = val;
623 }*/
627 OdUInt32 numFaceSamplePoints() const { return m_numFaceSamplePoints; }
633 void setNumFaceSamplePoints( OdUInt32 n ) { m_numFaceSamplePoints = n; }
634
635//DOM-IGNORE-BEGIN
636private:
637 enum OptionFlags
638 {
639 kFlag_FitNormals = 1,
640 kFlag_FitColors = 1 << 1,
641 kFlag_DesH = 1 << 2,
642 kFlag_DesN = 1 << 3
643 };
644 OdUInt8 m_flags;
645 OdUInt32 m_minVertices;
646 OdUInt32 m_minFaces;
647 double m_worstDiherial;
648 double m_worstCost;
649 double m_minCost;
650 double m_infinity;
651 double m_normalErrorFactor; //normal error (0..2) to dist/diam rms, need to constant in front of normal error term
652 double m_colorErrorFactor; //color rms (0..sqrt(3)) to dist/diam rms, need to constant in front of color error term
653 double m_sharpEdgesScaleFactor; //scale number of sharp edge samples
654 double m_nextCostThresholdFactor;
655 double m_desdFactor; //penalize diff max #desc to balance tree
656 double m_desnFactor; //penalize sum #desc to balance tree
657 OdUInt8 m_strictSharp; //disallow disc. curve topo type changes {0, 1, 2}
658 OdUInt32 m_numFaceSamplePoints; //number of face sample points, -1 means == face num
659//DOM-IGNORE-END
660};
661
679{
680public:
685 {
686 kStatus_Ok = 0, //Progressive mesh is OK
687 kStatus_DegenerateFacesIgnored = 1, //Some faces from input are skipped since they are degenerative
688 kStatus_NonManifoldFacesIgnored = 1 << 1, //Some faces from input are skipped since they cause non-manifold
689 kStatus_InvalidFacesIgnored = 1 << 2, //Some faces from input are skipped since they are invalid (not 3 or 4 points, contains points out of input points range, etc)
690 kStatus_ZeroNormalFacesIgnored = 1 << 3, //Some faces from input are skipped since they have zero normal
691 kStatus_NonTriangleFaceTriangulated = 1 << 4 //Some faces from input were not triangle and were triangulated
692 };
693
699
704
717 virtual OdUInt8 setupInitialShell( OdInt32 nPoints, const OdGePoint3d * points, OdInt32 faceListSize, const OdInt32 * faces ) = 0;
729 virtual OdGiProgressiveMeshPtr buildProgressiveMesh( const OdGiVertexData* pVertexData = NULL, const OdGiFaceData* pFaceData = NULL, const OdGiEdgeData* pEdgeData = NULL ) = 0;
751 const OdGiProgressiveMeshObjectIdConverter* pConverter = NULL,
765};
766
771class ODGI_EXPORT OdGiProgressiveMeshEx : public OdRxObject
772{
773public:
784 virtual bool obtainShell( OdVector< OdGePoint3d >& pts, OdVector< OdInt32 >& faces ) const = 0;
820 virtual OdUInt32 numLODs() const = 0;
829 virtual OdUInt32 currentLOD() const = 0;
837 virtual bool setLOD( OdUInt32 ) = 0;
843 virtual OdUInt32 numFaces() const = 0;
849 virtual OdUInt32 numVertices() const = 0;
855 virtual const OdGeExtents3d& extents() const = 0;
888 virtual bool isProgressiveMeshGenerated() const = 0;
898 virtual void setupInitialShell( OdInt32 nPoints, const OdGePoint3d * points, OdInt32 faceListSize, const OdInt32 * faces ) = 0;
913 virtual bool buildProgressiveMesh( const OdGiVertexData* pVertexData = NULL, const OdGiFaceData* pFaceData = NULL, const OdGiEdgeData* pEdgeData = NULL ) = 0;
940 virtual bool readProgressiveMeshExFrom( OdStreamBuf* pBuff, const OdGiProgressiveMeshObjectIdConverter* pConverter = NULL,
955 virtual bool readPartialProgressiveMeshExFrom( OdStreamBuf* pBuff, OdGiDataExtractor* pDataExtractor, const OdGiProgressiveMeshObjectIdConverter* pConverter = NULL,
957
980 virtual void setGenerationAbortFlags( OdUInt8 flags ) = 0;
986 virtual OdUInt8 generationAbortFlags() const = 0;
1003 virtual bool hasData() const = 0;
1008 virtual OdUInt64 getObjectSize() const = 0;
1009};
1010
1015
1016#endif
1017
1018
#define ODGI_EXPORT
Definition GiExport.h:35
OdSmartPtr< OdGiProgressiveMesh > OdGiProgressiveMeshPtr
OdSmartPtr< OdGiProgressiveMeshEx > OdGiProgressiveMeshExPtr
unsigned int OdUInt32
short OdInt16
int OdInt32
unsigned char OdUInt8
#define SETBIT(flags, bit, value)
Definition OdaDefs.h:516
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
virtual bool extractBool()
virtual bool seekFromLocalOffset(OdUInt64 offset)=0
virtual void extractBytes(void *buffer, OdUInt32 numBytes)=0
virtual OdInt64 extractInt64()
virtual OdInt32 extractInt32()
virtual OdInt16 extractInt16()
virtual bool registerDataBegin(OdUInt8 dataId, OdUInt64 localOffset)=0
virtual OdUInt8 extractByte()
virtual bool beginExtraction(OdUInt8 dataId)=0
virtual bool endExtraction(OdUInt8 dataId)=0
virtual OdUInt64 tell()=0
virtual double extractDouble()
virtual bool registerDataEnd(OdUInt8 dataId, OdUInt64 localOffset)=0
virtual OdUInt32 selectLOD(const OdGiProgressiveMesh *pPM, const OdGiViewport *pView, const OdGeMatrix3d *pModelToWorldTransform) const =0
virtual bool isProgressiveMeshGenerated() const =0
virtual void setOptions(const OdGiProgressiveMeshGeneratorOptions &)=0
virtual const OdGiProgressiveMeshGeneratorOptions & options() const =0
virtual OdUInt64 getObjectSize() const =0
virtual OdUInt32 obtainEdgeData(OdGiProgressiveMeshEdgeData &data, OdUInt32 flags) const =0
virtual void setGenerationAbortFlags(OdUInt8 flags)=0
virtual bool readProgressiveMeshExFrom(OdStreamBuf *pBuff, const OdGiProgressiveMeshObjectIdConverter *pConverter=NULL, OdGiProgressiveMesh::ProgressiveMeshStreamVersion version=OdGiProgressiveMesh::kVersionActual)=0
virtual bool buildProgressiveMesh(const OdGiVertexData *pVertexData=NULL, const OdGiFaceData *pFaceData=NULL, const OdGiEdgeData *pEdgeData=NULL)=0
virtual OdUInt8 generationAbortFlags() const =0
virtual OdUInt32 numLODs() const =0
virtual OdUInt32 currentLOD() const =0
virtual OdUInt32 numFaces() const =0
virtual OdUInt32 obtainFaceData(OdGiProgressiveMeshFaceData &data, OdUInt32 flags) const =0
virtual bool setLOD(OdUInt32)=0
virtual void setupInitialShell(OdInt32 nPoints, const OdGePoint3d *points, OdInt32 faceListSize, const OdInt32 *faces)=0
virtual OdGiProgressiveMeshPtr progressiveMesh() const =0
virtual void setProgressiveMesh(OdGiProgressiveMeshPtr pMesh)=0
virtual const OdGeExtents3d & extents() const =0
virtual bool obtainShell(OdVector< OdGePoint3d > &pts, OdVector< OdInt32 > &faces) const =0
ODRX_DECLARE_MEMBERS(OdGiProgressiveMeshEx)
virtual bool readPartialProgressiveMeshExFrom(OdStreamBuf *pBuff, OdGiDataExtractor *pDataExtractor, const OdGiProgressiveMeshObjectIdConverter *pConverter=NULL, OdGiProgressiveMesh::ProgressiveMeshStreamVersion version=OdGiProgressiveMesh::kVersionActual)=0
virtual OdGiProgressiveMeshGeneratorOptions & options()=0
virtual bool write(OdStreamBuf *pBuff, const OdGiProgressiveMeshObjectIdConverter *pConverter=NULL, OdGiProgressiveMesh::ProgressiveMeshStreamVersion version=OdGiProgressiveMesh::kVersionActual) const =0
virtual OdUInt32 obtainVertexData(OdGiProgressiveMeshVertexData &data, OdUInt32 flags) const =0
virtual OdUInt32 numVertices() const =0
virtual bool hasData() const =0
virtual const OdGiProgressiveMeshGeneratorOptions & options() const =0
virtual OdUInt8 setupInitialShell(OdInt32 nPoints, const OdGePoint3d *points, OdInt32 faceListSize, const OdInt32 *faces)=0
virtual OdGiProgressiveMeshPtr createPartialProgressiveMeshFrom(OdStreamBuf *pBuff, OdGiDataExtractor *pDataExtractor, const OdGiProgressiveMeshObjectIdConverter *pConverter=NULL, OdGiProgressiveMesh::ProgressiveMeshStreamVersion version=OdGiProgressiveMesh::kVersionActual) const =0
virtual OdGiProgressiveMeshGeneratorOptions & options()=0
static OdGiProgressiveMeshGenerator * createObject()
virtual OdGiProgressiveMeshPtr createProgressiveMeshFrom(OdStreamBuf *pBuff, const OdGiProgressiveMeshObjectIdConverter *pConverter=NULL, OdGiProgressiveMesh::ProgressiveMeshStreamVersion version=OdGiProgressiveMesh::kVersionActual) const =0
virtual OdGiProgressiveMeshPtr buildProgressiveMesh(const OdGiVertexData *pVertexData=NULL, const OdGiFaceData *pFaceData=NULL, const OdGiEdgeData *pEdgeData=NULL)=0
virtual void setOptions(const OdGiProgressiveMeshGeneratorOptions &)=0
void setSumPenalty(bool bSet, double factor)
void setFitNormals(bool bFit, double errorFactor)
void setDiffMaxPenalty(bool bSet, double factor)
void setFitColors(bool bFit, double errorFactor)
virtual OdGiProgressiveMeshAutoLODSelectOptions & autoSelectLODOptions()=0
virtual OdUInt32 obtainVertexData(OdGiProgressiveMeshVertexData &data, OdUInt32 flags) const =0
virtual bool isInPartialMode() const =0
virtual OdUInt32 currentLOD() const =0
virtual void endPartialMode()=0
ODRX_DECLARE_MEMBERS(OdGiProgressiveMesh)
virtual OdUInt32 numVertices() const =0
virtual OdGiProgressiveMeshAutoLODSelectCallback * getCustomLODAutoSelectCallback() const =0
virtual bool write(OdStreamBuf *pBuff, const OdGiProgressiveMeshObjectIdConverter *pConverter=NULL, ProgressiveMeshStreamVersion version=kVersionActual) const =0
virtual void setCustomLODAutoSelectCallback(OdGiProgressiveMeshAutoLODSelectCallback *pCallback)=0
virtual void setAutoSelectLODOptions(const OdGiProgressiveMeshAutoLODSelectOptions &options)=0
virtual bool setLOD(OdUInt32)=0
virtual OdUInt32 obtainFaceData(OdGiProgressiveMeshFaceData &data, OdUInt32 flags) const =0
virtual const OdGiProgressiveMeshAutoLODSelectOptions & autoSelectLODOptions() const =0
virtual OdUInt32 numFaces() const =0
virtual OdUInt64 getObjectSize() const =0
virtual OdUInt32 selectLOD(ProgressiveMeshAutoSelectLOD lod, const OdGiViewport *pView, const OdGeMatrix3d *pModelToWorldTransform=NULL)=0
virtual OdUInt32 obtainEdgeData(OdGiProgressiveMeshEdgeData &data, OdUInt32 flags) const =0
virtual bool obtainShell(OdVector< OdGePoint3d > &pts, OdVector< OdInt32 > &faces) const =0
virtual const OdGeExtents3d & extents() const =0
virtual OdUInt32 numLODs() const =0
virtual OdInt64 dbStubToInt(OdDbStub *) const =0
virtual OdDbStub * intToDbStub(OdInt64) const =0
GLuint buffer
Definition gles2_ext.h:178
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition gles2_ext.h:110
GLintptr offset
Definition gles2_ext.h:183
OdVector< OdUInt8 > visibilities
OdVector< OdGeVector3d > normals
OdVector< OdCmEntityColor > colors
OdVector< OdDbStub * > materials
OdVector< OdCmEntityColor > colors
OdVector< OdGeVector3d > normals