19 VisRTX::Context* rtx = VisRTX_GetContext();
22 this->geometry = rtx->CreateTriangleGeometry();
23 else if (type ==
"sphere")
24 this->geometry = rtx->CreateSphereGeometry();
25 else if (type ==
"curve")
26 this->geometry = rtx->CreateCylinderGeometry();
27 else if (type ==
"isosurfaces")
38 this->geometry->Release();
51 if (this->geometry->GetType() == VisRTX::GeometryType::TRIANGLES)
53 VisRTX::TriangleGeometry* tri =
dynamic_cast<VisRTX::TriangleGeometry*
>(this->geometry);
55 Data* vertex = this->GetObject<Data>({
"vertex.position",
"position",
"vertex" });
56 Data* index = this->GetObject<Data>({
"index" });
59 uint32_t numTriangles =
static_cast<uint32_t
>(index->GetNumElements());
60 VisRTX::Vec3ui* triangles =
reinterpret_cast<VisRTX::Vec3ui*
>(index->GetData());
61 assert(index->GetElementDataType() ==
RTW_VEC3UI);
63 uint32_t numVertices =
static_cast<uint32_t
>(vertex->
GetNumElements());
64 VisRTX::Vec3f*
vertices =
reinterpret_cast<VisRTX::Vec3f*
>(vertex->
GetData());
67 VisRTX::Vec3f* normals =
nullptr;
68 Data* normal = this->GetObject<Data>({
"vertex.normal" });
71 normals =
reinterpret_cast<VisRTX::Vec3f*
>(normal->
GetData());
76 tri->SetTriangles(numTriangles, triangles, numVertices,
vertices, normals);
79 Data* color = this->GetObject<Data>({
"vertex.color" });
82 VisRTX::Vec4f* colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
83 assert(color->GetElementDataType() ==
RTW_VEC4F);
84 tri->SetColors(colors);
88 tri->SetColors(
nullptr);
92 Data* texcoord = GetObject<Data>({
"vertex.texcoord" });
95 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
97 tri->SetTexCoords(texcoords);
101 tri->SetTexCoords(
nullptr);
104 Data* materialList = GetObject<Data>({
"material" });
109 std::vector<VisRTX::Material*> triangleMaterials;
110 triangleMaterials.resize(numTriangles);
114 for (uint32_t i = 0; i < numTriangles; ++i)
116 Material* materialHandle = materials[i];
118 triangleMaterials[i] = materialHandle->material;
121 tri->SetMaterials(triangleMaterials.data());
125 tri->SetMaterials(
nullptr);
130 tri->SetTriangles(0,
nullptr, 0,
nullptr,
nullptr);
138 else if (this->geometry->GetType() == VisRTX::GeometryType::SPHERES)
140 VisRTX::SphereGeometry* sphere =
dynamic_cast<VisRTX::SphereGeometry*
>(this->geometry);
142 Data* spheres = GetObject<Data>({
"sphere.position" });
145 VisRTX::Vec4f* colors =
nullptr;
146 Data* color = GetObject<Data>({
"color" });
149 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
150 assert(color->GetElementDataType() ==
RTW_VEC4F);
151 sphere->SetColors(
reinterpret_cast<VisRTX::Vec4f *
>(color->GetData()));
155 sphere->SetColors(
nullptr);
158 Data *radii = GetObject<Data>({
"sphere.radius"});
162 sphere->SetSpheres(numSpheres,
163 reinterpret_cast<VisRTX::Vec3f *
>(spheres->
GetData()),
164 reinterpret_cast<float *
>(radii->
GetData()));
169 sphere->SetSpheres(numSpheres,
170 reinterpret_cast<VisRTX::Vec3f *
>(spheres->
GetData()),
175 Data* texcoord = GetObject<Data>({
"sphere.texcoord" });
178 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
180 sphere->SetTexCoords(texcoords);
184 sphere->SetTexCoords(
nullptr);
187 Data* materialList = GetObject<Data>({
"material" });
193 std::vector<VisRTX::Material*> sphereMaterials;
194 sphereMaterials.resize(numSpheres);
198 for (uint32_t i = 0; i < numSpheres; ++i)
200 Material* materialHandle = materials[i];
202 sphereMaterials[i] = materialHandle->material;
205 sphere->SetMaterials(sphereMaterials.data());
209 sphere->SetMaterials(
nullptr);
218 if (this->
GetFloat({
"radius" }, &radius))
219 sphere->SetRadius(radius);
225 else if (this->geometry->GetType() == VisRTX::GeometryType::CYLINDERS)
227 VisRTX::CylinderGeometry* cyl =
dynamic_cast<VisRTX::CylinderGeometry*
>(this->geometry);
230 Data* cylinders = GetObject<Data>({
"vertex.position" });
233 VisRTX::Vec4f* colors =
nullptr;
234 Data* color = GetObject<Data>({
"color" });
237 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
238 assert(color->GetElementDataType() ==
RTW_VEC4F);
241 int32_t bytesPerCylinder = this->
GetInt({
"bytes_per_cylinder" }, 24,
nullptr);
242 int32_t offsetVertex0 = this->
GetInt({
"offset_v0" }, 0,
nullptr);
243 int32_t offsetVertex1 = this->
GetInt({
"offset_v1" }, 12,
nullptr);
244 int32_t offsetRadius = this->
GetInt({
"offset_radius" }, -1,
nullptr);
247 cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
250 Data* texcoord = GetObject<Data>({
"vertex.texcoord" });
253 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
255 cyl->SetTexCoords(texcoords);
259 cyl->SetTexCoords(
nullptr);
262 Data* materialList = GetObject<Data>({
"material" });
267 std::vector<VisRTX::Material*> cylinderMaterials;
268 cylinderMaterials.resize(numCylinders);
272 for (uint32_t i = 0; i < numCylinders; ++i)
274 Material* materialHandle = materials[i];
276 cylinderMaterials[i] = materialHandle->material;
279 cyl->SetMaterials(cylinderMaterials.data());
283 cyl->SetMaterials(
nullptr);
286 else if(cylinders = GetObject<Data>({
"vertex.position_radius"}))
289 VisRTX::Vec4f* colors =
nullptr;
290 Data* color = GetObject<Data>({
"color" });
293 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
294 assert(color->GetElementDataType() ==
RTW_VEC4F);
297 int32_t bytesPerCylinder = this->
GetInt({
"bytes_per_cylinder" }, 64,
nullptr);
298 int32_t offsetVertex0 = this->
GetInt({
"offset_v0" }, 0,
nullptr);
299 int32_t offsetVertex1 = this->
GetInt({
"offset_v1" }, 32,
nullptr);
300 int32_t offsetRadius = this->
GetInt({
"offset_radius" }, 12,
nullptr);
303 cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
306 Data* texcoord = GetObject<Data>({
"vertex.texcoord" });
309 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
311 cyl->SetTexCoords(texcoords);
315 cyl->SetTexCoords(
nullptr);
318 Data* materialList = GetObject<Data>({
"material" });
323 std::vector<VisRTX::Material*> cylinderMaterials;
324 cylinderMaterials.resize(numCylinders);
328 for (uint32_t i = 0; i < numCylinders; ++i)
330 Material* materialHandle = materials[i];
332 cylinderMaterials[i] = materialHandle->material;
335 cyl->SetMaterials(cylinderMaterials.data());
339 cyl->SetMaterials(
nullptr);
348 if (this->
GetFloat({
"radius" }, &radius))
349 cyl->SetRadius(radius);
361 VisRTX::Context* rtx = VisRTX_GetContext();
362 this->geometry->SetMaterial(rtx->CreateBasicMaterial());
377 this->geometry->SetMaterial(material->material);
378 this->material = material;
383 this->geometry->SetMaterial(
nullptr);
384 this->material =
nullptr;
389 VisRTX::Geometry* geometry =
nullptr;
size_t GetNumElements() const
static size_t GetElementSize(RTWDataType type)
RTWDataType GetElementDataType() const
Geometry(const std::string &type)
void SetMaterial(Material *material)
int32_t GetInt(const std::vector< std::string > &ids, int32_t defaultValue=0, bool *found=nullptr) const
float GetFloat(const std::vector< std::string > &ids, float defaultValue=0.0f, bool *found=nullptr) const
std::pair< boost::graph_traits< vtkGraph * >::vertex_iterator, boost::graph_traits< vtkGraph * >::vertex_iterator > vertices(vtkGraph *g)