OWL
Loading...
Searching...
No Matches
CurvesGeom.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 CurvesGeomType : public GeomType {
27 typedef std::shared_ptr<CurvesGeomType> 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 CurvesGeomType(Context *const context,
47 size_t varStructSize,
48 const std::vector<OWLVarDecl> &varDecls);
49
51 std::string toString() const override { return "CurvesGeomType"; }
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 void setDegree(int degree, bool force_caps);
62
64 int degree = 3;
65
69 bool forceCaps = false;
70 };
71
77 struct CurvesGeom : public Geom {
78
79 typedef std::shared_ptr<CurvesGeom> SP;
80
83 struct DeviceData : public Geom::DeviceData {
84 DeviceData(const DeviceContext::SP &device);
85
89 std::vector<CUdeviceptr> verticesPointers;
90
94 std::vector<CUdeviceptr> widthsPointers;
95
99 CUdeviceptr indicesPointer = (CUdeviceptr)0;
100 };
101
104 CurvesGeom(Context *const context,
105 GeomType::SP geometryType);
106
108 RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override;
112 inline DeviceData &getDD(const DeviceContext::SP &device);
113
115 CurvesGeomType::DeviceData &getTypeDD(const DeviceContext::SP &device) const;
116
119 void setVertices(const std::vector<Buffer::SP> &vertices,
120 const std::vector<Buffer::SP> &widths,
122 size_t count);
123
125 void setSegmentIndices(Buffer::SP indices,
126 size_t count);
127
129 std::string toString() const override;
130
131 int segmentIndicesCount = 0;
132 Buffer::SP segmentIndicesBuffer;
133
134 int vertexCount = 0;
135 std::vector<Buffer::SP> verticesBuffers;
136 std::vector<Buffer::SP> widthsBuffers;
137 };
138
139 // ------------------------------------------------------------------
140 // implementation section
141 // ------------------------------------------------------------------
142
145 CurvesGeomType::getDD(const DeviceContext::SP &device) const
146 {
147 assert(device && device->ID >= 0 && device->ID < (int)deviceData.size());
148 return deviceData[device->ID]->as<CurvesGeomType::DeviceData>();
149 }
150
153 CurvesGeom::getDD(const DeviceContext::SP &device)
154 {
155 assert(device && device->ID >= 0 && device->ID < (int)deviceData.size());
156 return deviceData[device->ID]->as<CurvesGeom::DeviceData>();
157 }
158
161 CurvesGeom::getTypeDD(const DeviceContext::SP &device) const
162 {
163 return (CurvesGeomType::DeviceData &)type->getDD(device);
164 }
165
166} // ::owl
Definition: Context.h:32
Definition: CurvesGeom.h:31
void fillPGDesc(OptixProgramGroupDesc &pgDesc, GeomType *gt, int rayType) override
DeviceData(const DeviceContext::SP &device)
Definition: CurvesGeom.h:26
bool forceCaps
Definition: CurvesGeom.h:69
std::shared_ptr< Geom > createGeom() override
int degree
Definition: CurvesGeom.h:64
DeviceData & getDD(const DeviceContext::SP &device) const
Definition: CurvesGeom.h:145
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
std::string toString() const override
Definition: CurvesGeom.h:51
Definition: CurvesGeom.h:83
std::vector< CUdeviceptr > verticesPointers
Definition: CurvesGeom.h:89
CUdeviceptr indicesPointer
Definition: CurvesGeom.h:99
std::vector< CUdeviceptr > widthsPointers
Definition: CurvesGeom.h:94
Definition: CurvesGeom.h:77
void setSegmentIndices(Buffer::SP indices, size_t count)
std::string toString() const override
RegisteredObject::DeviceData::SP createOn(const DeviceContext::SP &device) override
DeviceData & getDD(const DeviceContext::SP &device)
Definition: CurvesGeom.h:153
void setVertices(const std::vector< Buffer::SP > &vertices, const std::vector< Buffer::SP > &widths, size_t count)
CurvesGeom(Context *const context, GeomType::SP geometryType)
CurvesGeomType::DeviceData & getTypeDD(const DeviceContext::SP &device) const
Definition: CurvesGeom.h:161
Definition: Geometry.h:48
Definition: Geometry.h:41
Definition: Geometry.h:108
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