Giter Club home page Giter Club logo

Comments (8)

zhang-qiang-github avatar zhang-qiang-github commented on June 20, 2024 1

but to be honest I don't understand why flipping the normals is not equivalent to setting invert flag.

It is really weird. After add minus sign, it works for invert=True/False.

from vedo.

zhang-qiang-github avatar zhang-qiang-github commented on June 20, 2024 1

I have posted it in vtk forum: https://discourse.vtk.org/t/vtkclippolydata-incorrectly-work/13046

from vedo.

marcomusy avatar marcomusy commented on June 20, 2024

Yes: https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.cut_with_box

from vedo.

zhang-qiang-github avatar zhang-qiang-github commented on June 20, 2024

Yes: https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.cut_with_box

Thank you very much. I will try it.

from vedo.

zhang-qiang-github avatar zhang-qiang-github commented on June 20, 2024

Yes: https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.cut_with_box

If [xmin,xmax, ymin,ymax, zmin,zmax] is used to generate a cube, the direction is x=[1, 0, 0], y=[0, 1, 0], z=[0, 0, 1] . How can I generate a cube with specific direction?

Is it possible to create the box with topPoint1, topPoint2, topPoint3, topPoint4, bottomPoint1, bottomPoint2, bottomPoint3, bottomPoint4?

from vedo.

marcomusy avatar marcomusy commented on June 20, 2024

You may obtain the result by using 6 planes with
https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.cut_with_planes
or
https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.cut_with_plane

from vedo.

zhang-qiang-github avatar zhang-qiang-github commented on June 20, 2024

You may obtain the result by using 6 planes with https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.cut_with_planes or https://vedo.embl.es/autodocs/content/vedo/vedo/pointcloud.html#Points.cut_with_plane

I have tried it, but the result is wrong. My code is:

import vedo

mesh1 = vedo.Mesh('before.obj').alpha(0.3).color('r')

a = mesh1.bounds()
print(a)
centers=[
    [25.54791, 131.90236, 570.03764],
    [46.95663, 83.99182, 511.02341],
    [58.50379, 42.54272, 577.24325],
    [37.09508, 90.45326, 636.25748]
]
normals = [
    [0.34503, -0.93555, 0.07544],
    [-0.07840, 0.05137, 0.99560],
    [-0.34503, 0.93555, -0.07544],
    [0.07840, -0.05137, -0.99560]
]
planes = []
for i in range(4):
    p = vedo.Plane(pos=centers[i], normal=normals[i], s=[100, 100])
    planes.append(p)


mesh2 = mesh1.clone().cut_with_planes(origins=centers, normals=normals).color('b').alpha(0.3)

vedo.show(mesh1, planes, mesh2)

The test data is:

before.zip

The result of code is:

image

The four gray planes is used to cut the mesh. I hope the region included by the planes is cutted. But nothing is cutted.

Any suggestion is appreciated~~~

from vedo.

marcomusy avatar marcomusy commented on June 20, 2024

This seems to do the job:

import numpy as np
import vedo


mesh1 = vedo.Mesh("data/before.obj").color("r5", 0.3)
# print(mesh1)

centers = np.array([
    [25.54791, 131.9023, 570.03764],
    [46.95663, 83.99182, 511.02341],
    [58.50379, 42.54272, 577.24325],
    [37.09508, 90.45326, 636.25748],
])
normals = -np.array([   # NOTE THE MINUS SIGN
    [0.34503, -0.93555, 0.07544],
    [-0.07840, 0.05137, 0.99560],
    [-0.34503, 0.93555, -0.07544],
    [0.07840, -0.05137, -0.99560],
])

planes = []
for i in range(4):
    p = vedo.Plane(centers[i], normals[i], s=[100, 100])
    planes.append(p)

arrows = vedo.Arrows(centers, centers+normals*20, c="k")

mesh2 = mesh1.clone().cut_with_planes(centers, normals, invert=1)
mesh2.color("b5", 0.3)

vedo.show(planes, mesh2, arrows, axes=8)

Screenshot from 2024-01-08 12-14-30

but to be honest I don't understand why flipping the normals is not equivalent to setting invert flag.

from vedo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.