tessellation icon indicating copy to clipboard operation
tessellation copied to clipboard

can't get minimal exemple to work

Open bekraoui opened this issue 4 years ago • 4 comments

I’m interested in ploting 3D implicite functions, i was trying to compile the sphere exemple, unfortunatly i didn't success to compile it even i'm using a minimal code:

extern crate nalgebra;
extern crate tessellation;

use nalgebra as na;
/*//!*/
struct UnitSphere {
  bbox : tessellation::BoundingBox<f64>
}
/*//!*/
impl UnitSphere {
  fn new() -> UnitSphere {
    UnitSphere {
      bbox: tessellation::BoundingBox::new(&na::Point3::new(-1., -1., -1.),
                                           &na::Point3::new( 1.,  1.,  1.)) }
  }
}

impl tessellation::ImplicitFunction<f64> for UnitSphere {
   fn bbox(&self) -> &tessellation::BoundingBox<f64> {
     &self.bbox
   }
  fn value(&self, p: &na::Point3<f64>) -> f64 {
    na::Vector3::new(p.x, p.y, p.z).norm() - 1.0
  }
  fn normal(&self, p: &na::Point3<f64>) -> na::Vector3<f64> {
    na::Vector3::new(p.x, p.y, p.z).normalize()
  }
}


fn main() {

    let sphere = UnitSphere::new();
    let mut mdc =  tessellation::ManifoldDualContouring::new(&sphere, 0.2, 0.1);
    let triangles = mdc.tessellate().unwrap();

    println!("Hello, world!");
}

Can you help me solve this error please?

bekraoui avatar Sep 14 '21 22:09 bekraoui

Can you also post your error message, please?

bekraoui @.***> schrieb am Mi., 15. Sept. 2021, 00:04:

I’m interested in ploting 3D implicite functions, i was trying to compile the sphere exemple, unfortunatly i didn't success to compile it even i'm using a minimal code:

extern crate nalgebra;

extern crate tessellation;

use nalgebra as na;

///!/

struct UnitSphere {

bbox : tessellation::BoundingBox

}

///!/

impl UnitSphere {

fn new() -> UnitSphere {

UnitSphere {

  bbox: tessellation::BoundingBox::new(&na::Point3::new(-1., -1., -1.),

                                       &na::Point3::new( 1.,  1.,  1.)) }

}

}

impl tessellation::ImplicitFunction for UnitSphere {

fn bbox(&self) -> &tessellation::BoundingBox {

 &self.bbox

}

fn value(&self, p: &na::Point3) -> f64 {

na::Vector3::new(p.x, p.y, p.z).norm() - 1.0

}

fn normal(&self, p: &na::Point3) -> na::Vector3 {

na::Vector3::new(p.x, p.y, p.z).normalize()

}

}

fn main() {

let sphere = UnitSphere::new();

let mut mdc =  tessellation::ManifoldDualContouring::new(&sphere, 0.2, 0.1);

let triangles = mdc.tessellate().unwrap();



println!("Hello, world!");

}

Can you help me solve this error please?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hmeyer/tessellation/issues/11, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAE7LE7CZRXAFJC4XUHECLUB7BF7ANCNFSM5EBCYIHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

hmeyer avatar Sep 15 '21 04:09 hmeyer

This is the full error messages it seems that is uses some Opoint object instead of point :

   Compiling testiso v0.1.0 (/run/media/photon/2ad43a53-2f50-4f3d-801b-2a6938cc4a18/Projects/PixelCAE/testiso)
error[E0053]: method `value` has an incompatible type for trait
  --> src/main.rs:22:22
   |
22 |   fn value(&self, p: &na::Point3<f64>) -> f64 {
   |                      ^^^^^^^^^^^^^^^^
   |                      |
   |                      expected struct `nalgebra::geometry::point::Point`, found struct `OPoint`
   |                      help: change the parameter type to match the trait: `&nalgebra::geometry::point::Point<f64, nalgebra::base::dimension::U3>`
   |
   = note: expected fn pointer `fn(&UnitSphere, &nalgebra::geometry::point::Point<f64, nalgebra::base::dimension::U3>) -> _`
              found fn pointer `fn(&UnitSphere, &OPoint<f64, Const<3_usize>>) -> _`

error[E0053]: method `normal` has an incompatible type for trait
  --> src/main.rs:25:23
   |
25 |   fn normal(&self, p: &na::Point3<f64>) -> na::Vector3<f64> {
   |                       ^^^^^^^^^^^^^^^^
   |                       |
   |                       expected struct `nalgebra::geometry::point::Point`, found struct `OPoint`
   |                       help: change the parameter type to match the trait: `&nalgebra::geometry::point::Point<f64, nalgebra::base::dimension::U3>`
   |
   = note: expected fn pointer `fn(&UnitSphere, &nalgebra::geometry::point::Point<f64, nalgebra::base::dimension::U3>) -> nalgebra::base::matrix::Matrix<f64, nalgebra::base::dimension::U3, nalgebra::base::dimension::U1, nalgebra::base::array_storage::ArrayStorage<f64, nalgebra::base::dimension::U3, nalgebra::base::dimension::U1>>`
              found fn pointer `fn(&UnitSphere, &OPoint<f64, Const<3_usize>>) -> Matrix<f64, Const<3_usize>, Const<1_usize>, ArrayStorage<f64, 3_usize, 1_usize>>`

error[E0308]: mismatched types
  --> src/main.rs:13:44
   |
13 |       bbox: tessellation::BoundingBox::new(&na::Point3::new(-1., -1., -1.),
   |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `nalgebra::geometry::point::Point`, found struct `OPoint`
   |
   = note: expected reference `&nalgebra::geometry::point::Point<f64, nalgebra::base::dimension::U3>`
              found reference `&OPoint<{float}, Const<3_usize>>`

error[E0308]: mismatched types
  --> src/main.rs:14:44
   |
14 | ...                   &na::Point3::new( 1.,  1.,  1.)) }
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `nalgebra::geometry::point::Point`, found struct `OPoint`
   |
   = note: expected reference `&nalgebra::geometry::point::Point<f64, nalgebra::base::dimension::U3>`
              found reference `&OPoint<{float}, Const<3_usize>>`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0053, E0308.
For more information about an error, try `rustc --explain E0053`.
error: could not compile `testiso`

bekraoui avatar Sep 15 '21 13:09 bekraoui

my cargo.toml:

[package]
name = "testiso"
version = "0.1.0"
edition = "2018"

[dependencies]
nalgebra = "0.29.0"
tessellation = "0.8.2"

bekraoui avatar Sep 15 '21 13:09 bekraoui

As you can see in this minimal example i'm not using any library than "nalgebra" and "tesselation". And i didn't define any opoint object.

bekraoui avatar Sep 15 '21 13:09 bekraoui