8 #include <vtkFlyingEdges3D.h>
9 #include <vtkLinearExtrusionFilter.h>
11 #include <vtkTextSource.h>
12 #include <vtkTriangleFilter.h>
41 core::Tensor::Init<double>({{0.0, 0.0, 0.0},
59 core::Tensor triangle_indices = core::Tensor::Init<int64_t>({{4, 7, 5},
91 std::shared_ptr<ccMesh> legacy_mesh =
142 std::shared_ptr<ccMesh> legacy_mesh =
158 std::shared_ptr<ccMesh> legacy_mesh =
169 int radial_resolution,
170 int tubular_resolution,
175 torus_radius, tube_radius, radial_resolution, tubular_resolution);
185 double cylinder_height,
194 cylinder_radius, cone_radius, cylinder_height, cone_height,
195 resolution, cylinder_split, cone_split);
204 const Eigen::Vector3d &origin,
208 std::shared_ptr<ccMesh> legacy_mesh =
228 length_split, width_split, twists, radius, flatness,
width, scale);
241 using namespace vtkutils;
252 vtkNew<vtkTextSource> vector_text;
253 vector_text->SetText(text.c_str());
254 vector_text->BackingOff();
256 vtkNew<vtkLinearExtrusionFilter> extrude;
257 vtkNew<vtkTriangleFilter> triangle_filter;
259 extrude->SetInputConnection(vector_text->GetOutputPort());
260 extrude->SetExtrusionTypeToNormalExtrusion();
261 extrude->SetVector(0, 0, 1);
262 extrude->SetScaleFactor(depth);
264 triangle_filter->SetInputConnection(extrude->GetOutputPort());
266 triangle_filter->SetInputConnection(vector_text->GetOutputPort());
269 triangle_filter->Update();
270 auto polydata = triangle_filter->GetOutput();
272 tmesh.GetVertexPositions() =
273 tmesh.GetVertexPositions().To(device, float_dtype);
274 tmesh.GetTriangleIndices() =
275 tmesh.GetTriangleIndices().To(device, int_dtype);
281 const std::vector<double> contour_values,
283 using namespace vtkutils;
289 vtkNew<vtkFlyingEdges3D> method;
290 method->SetNumberOfContours(contour_values.size());
291 for (
int i = 0; i < int(contour_values.size()); ++i) {
292 method->SetValue(i, contour_values[i]);
294 method->SetInputData(image_data);
296 auto polydata = method->GetOutput();
298 return tmesh.To(device);
#define AssertTensorDtypes(tensor,...)
#define AssertTensorShape(tensor,...)
static std::shared_ptr< ccMesh > CreateCylinder(double radius=1.0, double height=2.0, int resolution=20, int split=4, bool create_uv_map=false)
static std::shared_ptr< ccMesh > CreateArrow(double cylinder_radius=1.0, double cone_radius=1.5, double cylinder_height=5.0, double cone_height=4.0, int resolution=20, int cylinder_split=4, int cone_split=1)
static std::shared_ptr< ccMesh > CreateCoordinateFrame(double size=1.0, const Eigen::Vector3d &origin=Eigen::Vector3d(0.0, 0.0, 0.0))
static std::shared_ptr< ccMesh > CreateMobius(int length_split=70, int width_split=15, int twists=1, double radius=1, double flatness=1, double width=1, double scale=1)
static std::shared_ptr< ccMesh > CreateIcosahedron(double radius=1.0, bool create_uv_map=false)
static std::shared_ptr< ccMesh > CreateTetrahedron(double radius=1.0, bool create_uv_map=false)
static std::shared_ptr< ccMesh > CreateCone(double radius=1.0, double height=2.0, int resolution=20, int split=1, bool create_uv_map=false)
static std::shared_ptr< ccMesh > CreateSphere(double radius=1.0, int resolution=20, bool create_uv_map=false)
static std::shared_ptr< ccMesh > CreateTorus(double torus_radius=1.0, double tube_radius=0.5, int radial_resolution=30, int tubular_resolution=20)
static std::shared_ptr< ccMesh > CreateOctahedron(double radius=1.0, bool create_uv_map=false)
std::string ToString() const
Tensor To(Dtype dtype, bool copy=false) const
A triangle mesh contains vertices and triangles.
static TriangleMesh CreateBox(double width=1.0, double height=1.0, double depth=1.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateIsosurfaces(const core::Tensor &volume, const std::vector< double > contour_values={0.0}, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateCylinder(double radius=1.0, double height=2.0, int resolution=20, int split=4, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateTetrahedron(double radius=1.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static geometry::TriangleMesh FromLegacy(const ccMesh &mesh_legacy, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateIcosahedron(double radius=1.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateText(const std::string &text, double depth=0.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateArrow(double cylinder_radius=1.0, double cone_radius=1.5, double cylinder_height=5.0, double cone_height=4.0, int resolution=20, int cylinder_split=4, int cone_split=1, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateMobius(int length_split=70, int width_split=15, int twists=1, double radius=1, double flatness=1, double width=1, double scale=1, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateCoordinateFrame(double size=1.0, const Eigen::Vector3d &origin=Eigen::Vector3d(0.0, 0.0, 0.0), core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateCone(double radius=1.0, double height=2.0, int resolution=20, int split=1, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateTorus(double torus_radius=1.0, double tube_radius=0.5, int radial_resolution=30, int tubular_resolution=20, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateOctahedron(double radius=1.0, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
static TriangleMesh CreateSphere(double radius=1.0, int resolution=20, core::Dtype float_dtype=core::Float32, core::Dtype int_dtype=core::Int64, const core::Device &device=core::Device("CPU:0"))
constexpr utility::nullopt_t None
TriangleMesh CreateTriangleMeshFromVtkPolyData(vtkPolyData *polydata, bool copy)
CLOUDVIEWER_LOCAL vtkSmartPointer< vtkImageData > CreateVtkImageDataFromTensor(core::Tensor &tensor, bool copy)
Generic file read and write utility for python interface.