13VTK_ABI_NAMESPACE_BEGIN
22 VisRTX::Context* rtx = VisRTX_GetContext();
25 this->geometry = rtx->CreateTriangleGeometry();
26 else if (type ==
"sphere")
27 this->geometry = rtx->CreateSphereGeometry();
28 else if (type ==
"curve")
29 this->geometry = rtx->CreateCylinderGeometry();
30 else if (type ==
"isosurfaces")
41 this->geometry->Release();
54 if (this->geometry->GetType() == VisRTX::GeometryType::TRIANGLES)
56 VisRTX::TriangleGeometry* tri =
dynamic_cast<VisRTX::TriangleGeometry*
>(this->geometry);
58 Data* vertex = this->GetObject<Data>({
"vertex.position",
"position",
"vertex" });
59 Data* index = this->GetObject<Data>({
"index" });
62 uint32_t numTriangles =
static_cast<uint32_t
>(index->GetNumElements());
63 VisRTX::Vec3ui* triangles =
reinterpret_cast<VisRTX::Vec3ui*
>(index->GetData());
64 assert(index->GetElementDataType() ==
RTW_VEC3UI);
66 uint32_t numVertices =
static_cast<uint32_t
>(vertex->
GetNumElements());
67 VisRTX::Vec3f*
vertices =
reinterpret_cast<VisRTX::Vec3f*
>(vertex->
GetData());
70 VisRTX::Vec3f* normals =
nullptr;
71 Data* normal = this->GetObject<Data>({
"vertex.normal" });
74 normals =
reinterpret_cast<VisRTX::Vec3f*
>(normal->
GetData());
79 tri->SetTriangles(numTriangles, triangles, numVertices,
vertices, normals);
82 Data* color = this->GetObject<Data>({
"vertex.color" });
85 VisRTX::Vec4f* colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
86 assert(color->GetElementDataType() ==
RTW_VEC4F);
87 tri->SetColors(colors);
91 tri->SetColors(
nullptr);
95 Data* texcoord = GetObject<Data>({
"vertex.texcoord" });
98 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
100 tri->SetTexCoords(texcoords);
104 tri->SetTexCoords(
nullptr);
107 Data* materialList = GetObject<Data>({
"material" });
112 std::vector<VisRTX::Material*> triangleMaterials;
113 triangleMaterials.resize(numTriangles);
117 for (uint32_t i = 0; i < numTriangles; ++i)
119 Material* materialHandle = materials[i];
121 triangleMaterials[i] = materialHandle->material;
124 tri->SetMaterials(triangleMaterials.data());
128 tri->SetMaterials(
nullptr);
133 tri->SetTriangles(0,
nullptr, 0,
nullptr,
nullptr);
141 else if (this->geometry->GetType() == VisRTX::GeometryType::SPHERES)
143 VisRTX::SphereGeometry* sphere =
dynamic_cast<VisRTX::SphereGeometry*
>(this->geometry);
145 Data* spheres = GetObject<Data>({
"sphere.position" });
148 VisRTX::Vec4f* colors =
nullptr;
149 Data* color = GetObject<Data>({
"color" });
152 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
153 assert(color->GetElementDataType() ==
RTW_VEC4F);
154 sphere->SetColors(
reinterpret_cast<VisRTX::Vec4f *
>(color->GetData()));
158 sphere->SetColors(
nullptr);
161 Data *radii = GetObject<Data>({
"sphere.radius"});
165 sphere->SetSpheres(numSpheres,
166 reinterpret_cast<VisRTX::Vec3f *
>(spheres->
GetData()),
167 reinterpret_cast<float *
>(radii->
GetData()));
172 sphere->SetSpheres(numSpheres,
173 reinterpret_cast<VisRTX::Vec3f *
>(spheres->
GetData()),
178 Data* texcoord = GetObject<Data>({
"sphere.texcoord" });
181 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
183 sphere->SetTexCoords(texcoords);
187 sphere->SetTexCoords(
nullptr);
190 Data* materialList = GetObject<Data>({
"material" });
196 std::vector<VisRTX::Material*> sphereMaterials;
197 sphereMaterials.resize(numSpheres);
201 for (uint32_t i = 0; i < numSpheres; ++i)
203 Material* materialHandle = materials[i];
205 sphereMaterials[i] = materialHandle->material;
208 sphere->SetMaterials(sphereMaterials.data());
212 sphere->SetMaterials(
nullptr);
221 if (this->
GetFloat({
"radius" }, &radius))
222 sphere->SetRadius(radius);
228 else if (this->geometry->GetType() == VisRTX::GeometryType::CYLINDERS)
230 VisRTX::CylinderGeometry* cyl =
dynamic_cast<VisRTX::CylinderGeometry*
>(this->geometry);
233 Data* cylinders = GetObject<Data>({
"vertex.position" });
236 VisRTX::Vec4f* colors =
nullptr;
237 Data* color = GetObject<Data>({
"color" });
240 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
241 assert(color->GetElementDataType() ==
RTW_VEC4F);
244 int32_t bytesPerCylinder = this->
GetInt({
"bytes_per_cylinder" }, 24,
nullptr);
245 int32_t offsetVertex0 = this->
GetInt({
"offset_v0" }, 0,
nullptr);
246 int32_t offsetVertex1 = this->
GetInt({
"offset_v1" }, 12,
nullptr);
247 int32_t offsetRadius = this->
GetInt({
"offset_radius" }, -1,
nullptr);
250 cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
253 Data* texcoord = GetObject<Data>({
"vertex.texcoord" });
256 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
258 cyl->SetTexCoords(texcoords);
262 cyl->SetTexCoords(
nullptr);
265 Data* materialList = GetObject<Data>({
"material" });
270 std::vector<VisRTX::Material*> cylinderMaterials;
271 cylinderMaterials.resize(numCylinders);
275 for (uint32_t i = 0; i < numCylinders; ++i)
277 Material* materialHandle = materials[i];
279 cylinderMaterials[i] = materialHandle->material;
282 cyl->SetMaterials(cylinderMaterials.data());
286 cyl->SetMaterials(
nullptr);
289 else if(cylinders = GetObject<Data>({
"vertex.position_radius"}))
292 VisRTX::Vec4f* colors =
nullptr;
293 Data* color = GetObject<Data>({
"color" });
296 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
297 assert(color->GetElementDataType() ==
RTW_VEC4F);
300 int32_t bytesPerCylinder = this->
GetInt({
"bytes_per_cylinder" }, 64,
nullptr);
301 int32_t offsetVertex0 = this->
GetInt({
"offset_v0" }, 0,
nullptr);
302 int32_t offsetVertex1 = this->
GetInt({
"offset_v1" }, 32,
nullptr);
303 int32_t offsetRadius = this->
GetInt({
"offset_radius" }, 12,
nullptr);
306 cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
309 Data* texcoord = GetObject<Data>({
"vertex.texcoord" });
312 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
314 cyl->SetTexCoords(texcoords);
318 cyl->SetTexCoords(
nullptr);
321 Data* materialList = GetObject<Data>({
"material" });
326 std::vector<VisRTX::Material*> cylinderMaterials;
327 cylinderMaterials.resize(numCylinders);
331 for (uint32_t i = 0; i < numCylinders; ++i)
333 Material* materialHandle = materials[i];
335 cylinderMaterials[i] = materialHandle->material;
338 cyl->SetMaterials(cylinderMaterials.data());
342 cyl->SetMaterials(
nullptr);
351 if (this->
GetFloat({
"radius" }, &radius))
352 cyl->SetRadius(radius);
364 VisRTX::Context* rtx = VisRTX_GetContext();
365 this->geometry->SetMaterial(rtx->CreateBasicMaterial());
380 this->geometry->SetMaterial(material->material);
381 this->material = material;
386 this->geometry->SetMaterial(
nullptr);
387 this->material =
nullptr;
392 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)