OWL
Loading...
Searching...
No Matches
SphereGeom.h
1// ======================================================================== //
2// Copyright 2019-2021 Ingo Wald //
3// //
4// Licensed under the Apache License, Version 2.0 (the "License"); //
5// you may not use this file except in compliance with the License. //
6// You may obtain a copy of the License at //
7// //
8// http://www.apache.org/licenses/LICENSE-2.0 //
9// //
10// Unless required by applicable law or agreed to in writing, software //
11// distributed under the License is distributed on an "AS IS" BASIS, //
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
13// See the License for the specific language governing permissions and //
14// limitations under the License. //
15// ======================================================================== //
16
17#pragma once
18
19#include "Geometry.h"
20
21namespace owl {
22
26 struct SphereGeomType : public GeomType {
27 typedef std::shared_ptr<SphereGeomType> SP;
28
32 typedef std::shared_ptr<DeviceData> SP;
33
35 DeviceData(const DeviceContext::SP &device);
36
41 void fillPGDesc(OptixProgramGroupDesc &pgDesc,
42 GeomType *gt,
43 int rayType) override;
44 };
45
46 SphereGeomType(Context *const context,
47 size_t varStructSize,
48 const std::vector<OWLVarDecl> &varDecls);
49
51 std::string toString() const override { return "SphereGeomType"; }
52
53 std::shared_ptr<Geom> createGeom() override;
54
56 inline DeviceData &getDD(const DeviceContext::SP &device) const;
57
59 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
60 };
61
67 struct SphereGeom : public Geom {
68
69 typedef std::shared_ptr<SphereGeom> SP;
70
73 struct DeviceData : public Geom::DeviceData {
74 DeviceData(const DeviceContext::SP &device);
75
79 std::vector<CUdeviceptr> verticesPointers;
80
84 std::vector<CUdeviceptr> radiusPointers;
85 };
86
89 SphereGeom(Context *const context,
90 GeomType::SP geometryType);
91
93 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
97 inline DeviceData &getDD(const DeviceContext::SP &device);
98
100 SphereGeomType::DeviceData &getTypeDD(const DeviceContext::SP &device) const;
101
104 void setVertices(const std::vector<Buffer::SP> &vertices,
105 const std::vector<Buffer::SP> &radii,
107 size_t count);
108
110 std::string toString() const override;
111
112 int vertexCount = 0;
113 std::vector<Buffer::SP> verticesBuffers;
114 std::vector<Buffer::SP> radiusBuffers;
115 };
116
117 // ------------------------------------------------------------------
118 // implementation section
119 // ------------------------------------------------------------------
120
123 SphereGeomType::getDD(const DeviceContext::SP &device) const
124 {
125 assert(device && device->ID >= 0 && device->ID < (int)deviceData.size());
126 return deviceData[device->ID]->as<SphereGeomType::DeviceData>();
127 }
128
131 SphereGeom::getDD(const DeviceContext::SP &device)
132 {
133 assert(device && device->ID >= 0 && device->ID < (int)deviceData.size());
134 return deviceData[device->ID]->as<SphereGeom::DeviceData>();
135 }
136
139 SphereGeom::getTypeDD(const DeviceContext::SP &device) const
140 {
141 return (SphereGeomType::DeviceData &)type->getDD(device);
142 }
143
144} // ::owl
Definition: Context.h:32
Definition: Geometry.h:48
Definition: Geometry.h:41
Definition: Geometry.h:108
Definition: Object.h:36
DeviceContext::SP device
Definition: Object.h:53
std::vector< DeviceData::SP > deviceData
Definition: Object.h:86
const std::vector< OWLVarDecl > varDecls
Definition: SBTObject.h:70
const size_t varStructSize
Definition: SBTObject.h:66
std::shared_ptr< GeomType > const type
Definition: SBTObject.h:134
Definition: SphereGeom.h:31
DeviceData(const DeviceContext::SP &device)
void fillPGDesc(OptixProgramGroupDesc &pgDesc, GeomType *gt, int rayType) override
Definition: SphereGeom.h:26
DeviceData & getDD(const DeviceContext::SP &device) const
Definition: SphereGeom.h:123
std::shared_ptr< Geom > createGeom() override
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
std::string toString() const override
Definition: SphereGeom.h:51
Definition: SphereGeom.h:73
std::vector< CUdeviceptr > verticesPointers
Definition: SphereGeom.h:79
std::vector< CUdeviceptr > radiusPointers
Definition: SphereGeom.h:84
Definition: SphereGeom.h:67
SphereGeomType::DeviceData & getTypeDD(const DeviceContext::SP &device) const
Definition: SphereGeom.h:139
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
void setVertices(const std::vector< Buffer::SP > &vertices, const std::vector< Buffer::SP > &radii, size_t count)
std::string toString() const override
SphereGeom(Context *const context, GeomType::SP geometryType)
DeviceData & getDD(const DeviceContext::SP &device)
Definition: SphereGeom.h:131