Main Page Class List Class Members

# sdk/extensions/authoringCommon/include/NvBlastExtAuthoringAccelerator.h

Go to the documentation of this file.

    00001 // This code contains NVIDIA Confidential Information and is disclosed to you
    00002 // under a form of NVIDIA software license agreement provided separately to you.
    00003 //
    00004 // Notice
    00005 // NVIDIA Corporation and its licensors retain all intellectual property and
    00006 // proprietary rights in and to this software and related documentation and
    00007 // any modifications thereto. Any use, reproduction, disclosure, or
    00008 // distribution of this software and related documentation without an express
    00009 // license agreement from NVIDIA Corporation is strictly prohibited.
    00010 //
    00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
    00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
    00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
    00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
    00015 //
    00016 // Information and code furnished is believed to be accurate and reliable.
    00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
    00018 // information or for any infringement of patents or other rights of third parties that may
    00019 // result from its use. No license is granted by implication or otherwise under any patent
    00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
    00021 // This code supersedes and replaces all information previously supplied.
    00022 // NVIDIA Corporation products are not authorized for use as critical
    00023 // components in life support devices or systems without express written approval of
    00024 // NVIDIA Corporation.
    00025 //
    00026 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
    00027
    00028
    00029 #ifndef NVBLASTEXTAUTHORINGACCELERATOR_H
    00030 #define NVBLASTEXTAUTHORINGACCELERATOR_H
    00031
    00032 #include <set>
    00033 #include <vector>
    00034 #include "NvBlastExtAuthoringTypes.h"
    00035
    00036
    00037 namespace Nv
    00038 {
    00039     namespace Blast
    00040     {
    00041
    00042         class Mesh;
    00043
    00047         class SpatialAccelerator
    00048         {
    00049         public:
    00050
    00057             virtual void    setState(const NvcBounds3* bounds) = 0;
    00058
    00065             virtual void    setState(const Vertex* pos, const Edge* ed, const Facet& fc) = 0;
    00070             virtual void    setState(const NvcVec3& point) = 0;
    00075             virtual int32_t getNextFacet() = 0;
    00076
    00077
    00078             virtual void setPointCmpDirection(int32_t dir) = 0;
    00079
    00080
    00081             virtual ~SpatialAccelerator() {};
    00082         };
    00083
    00084
    00088         class DummyAccelerator : public SpatialAccelerator
    00089         {
    00090         public:
    00094             DummyAccelerator(int32_t count);
    00095             virtual void    setState(const NvcBounds3* bounds) override;
    00096             virtual void setState(const Vertex* pos, const Edge* ed, const Facet& fc) override;
    00097             virtual void setState(const NvcVec3& point) override;
    00098             virtual int32_t getNextFacet() override;
    00099
    00100             virtual void setPointCmpDirection(int32_t dir) override {};
    00101         private:
    00102             int32_t m_count;
    00103             int32_t m_current;
    00104         };
    00105
    00106         struct SegmentToIndex
    00107         {
    00108             float coord;
    00109             uint32_t index;
    00110             bool end;
    00111
    00112             SegmentToIndex(float c, uint32_t i, bool end) : coord(c), index(i), end(end) {};
    00113
    00114             bool operator<(const SegmentToIndex& in) const
    00115             {
    00116                 if (coord < in.coord) return true;
    00117                 if (coord > in.coord) return false;
    00118                 return end < in.end;
    00119             }
    00120         };
    00121
    00122
    00123
    00124         class Grid
    00125         {
    00126
    00127         public:
    00128
    00129             friend class GridWalker;
    00130
    00131             Grid(int32_t resolution);
    00132             void setMesh(const Nv::Blast::Mesh* m);
    00133
    00134         private:
    00135             int32_t m_resolution;
    00136             int32_t m_r3;
    00137             int32_t m_mappedFacetCount;
    00138             NvcVec3 m_spos;
    00139             NvcVec3 m_deltas;
    00140             std::vector< std::vector<int32_t> > m_spatialMap;
    00141         };
    00142
    00143         class GridWalker : public SpatialAccelerator // Iterator to traverse the grid
    00144         {
    00145         public:
    00146             GridWalker(Grid* grd);
    00147
    00148             virtual void    setState(const NvcBounds3* bounds) override;
    00149             virtual void    setState(const Vertex* pos, const Edge* ed, const Facet& fc) override;
    00150             virtual void    setState(const NvcVec3& point) override;
    00151             virtual int32_t getNextFacet() override;
    00152             virtual void    setPointCmpDirection(int32_t dir) override;
    00153         private:
    00154             Grid* m_grid;
    00155
    00156             // Iterator data
    00157             std::vector<uint32_t> m_alreadyGotFlag;
    00158             uint32_t m_alreadyGotValue;
    00159             std::vector<int32_t> m_cellList;
    00160             int32_t m_gotCells;
    00161             int32_t m_iteratorCell;
    00162             int32_t m_iteratorFacet;
    00163             int32_t m_pointCmdDir;
    00164         };
    00165
    00166
    00167         class SweepingAccelerator : public SpatialAccelerator
    00168         {
    00169         public:
    00173             SweepingAccelerator(Nv::Blast::Mesh* in);
    00174             virtual void setState(const Vertex* pos, const Edge* ed, const Facet& fc) override;
    00175             virtual void    setState(const NvcBounds3* bounds) override;
    00176             virtual void setState(const NvcVec3& point) override;
    00177             virtual int32_t getNextFacet() override;
    00178             virtual void setPointCmpDirection(int32_t dir) override {};
    00179         private:
    00180
    00181
    00182             /*
    00183                 For fast point test.
    00184             */
    00185             std::vector<std::vector<uint32_t> > m_xSegm;
    00186             std::vector<std::vector<uint32_t> > m_ySegm;
    00187             std::vector<std::vector<uint32_t> > m_zSegm;
    00188             std::vector<uint32_t> m_indices;
    00189             std::vector<uint32_t> m_foundx;
    00190             std::vector<uint32_t> m_foundy;
    00191
    00192             uint32_t m_iterId;
    00193             int32_t m_current;
    00194             uint32_t m_facetCount;
    00195
    00196             NvcVec3 m_minimal;
    00197             NvcVec3 m_maximal;
    00198
    00199             NvcVec3 m_rescale;
    00200
    00201
    00202         };
    00203
    00204
    00210         class BBoxBasedAccelerator : public SpatialAccelerator
    00211         {
    00212         public:
    00217             BBoxBasedAccelerator(const Mesh* mesh, int32_t resolution);
    00218             virtual ~BBoxBasedAccelerator();
    00219             int32_t getNextFacet() override;
    00220             void setState(const Vertex* pos, const Edge* ed, const Facet& fc) override;
    00221             void setState(const NvcBounds3* bounds) override;
    00222             void setState(const NvcVec3& p) override;
    00223             void setPointCmpDirection(int32_t dir) override {};
    00224         private:
    00225
    00226             void buildAccelStructure(const Vertex* pos, const Edge* edges, const Facet* fc, int32_t facetCount);
    00227
    00228             int32_t m_resolution;
    00229             NvcBounds3 m_bounds;
    00230             std::vector< std::vector<int32_t> > m_spatialMap;
    00231             std::vector<NvcBounds3> m_cells;
    00232
    00233
    00234             // Iterator data
    00235             std::vector<uint32_t> m_alreadyGotFlag;
    00236             uint32_t m_alreadyGotValue;
    00237             std::vector<int32_t> m_cellList;
    00238             int32_t m_gotCells;
    00239             int32_t m_iteratorCell;
    00240             int32_t m_iteratorFacet;
    00241         };
    00242
    00243     } // namespace Blast
    00244 } // namsepace Nv
    00245
    00246
    00247 #endif // ifndef NVBLASTEXTAUTHORINGACCELERATOR_H