### Flatten and Render to STEP Format Source: https://docs.rs/monstertruck/0.3.2/src/monstertruck/lib.rs.html?search= This snippet demonstrates flattening a topology and rendering it into the STEP file format. It includes assertions to verify the output starts with the correct header and contains expected keywords. ```rust #![allow(unused_variables)] fn main() { //! let punched = solid::and(&cube, &cylinder, 0.05)?; //! //! // Flatten the topology and render as STEP. //! let compressed = punched.compress(); //! let step = CompleteStepDisplay::new( //! StepModel::from(&compressed), //! StepHeaderDescriptor { //! organization_system: "monstertruck-doc".to_owned(), //! ..Default::default() //! }, //! ) //! .to_string(); //! //! assert!(step.starts_with("ISO-10303-21;")); //! assert!(step.contains("MANIFOLD_SOLID_BREP")); //! # Ok(()) //! # } //! ``` ``` -------------------------------- ### Subtract Cylinder from Cube and Export STEP Source: https://docs.rs/monstertruck/0.3.2/src/monstertruck/lib.rs.html This example demonstrates building a cuboid and a cylinder, performing a boolean subtraction, and exporting the result as a STEP string. It requires the 'step' and 'solid' features to be enabled. ```rust # #[cfg(not(all(feature = "step", feature = "solid")))] # fn main() {} # #[cfg(all(feature = "step", feature = "solid"))] # fn main() -> anyhow::Result<()> { use monstertruck::modeling::* use monstertruck::solid; use monstertruck::step::save::{CompleteStepDisplay, StepHeaderDescriptor, StepModel}; // Unit cuboid centred on the origin. let cube: Solid = primitive::cuboid(BoundingBox::from_iter([ Point3::new(-0.5, -0.5, 0.0), Point3::new(0.5, 0.5, 1.0), ])); // Cylinder of radius 0.3, axis along +Z, that pierces the cube top to bottom. let seed = builder::vertex(Point3::new(0.3, 0.0, -0.1)); let rim = builder::revolve( &seed, Point3::new(0.0, 0.0, -0.1), Vector3::unit_z(), builder::SweepAngle::Closed, 4, ); let base = builder::try_attach_plane(&[rim])?; let mut cylinder: Solid = builder::extrude(&base, Vector3::unit_z() * 1.2); // Invert the cylinder so `and` performs a subtraction. cylinder.not(); ``` -------------------------------- ### Subtract Cylinder from Box and Export STEP Source: https://docs.rs/monstertruck/0.3.2/monstertruck/index.html?search= This example demonstrates building a cuboid and a cylinder, performing a boolean subtraction using the 'and' operation (after inverting the cylinder), and exporting the resulting solid as a STEP file string. Ensure 'modeling' and 'step' features are enabled. ```rust use monstertruck::modeling::* use monstertruck::solid use monstertruck::step::save::{CompleteStepDisplay, StepHeaderDescriptor, StepModel} // Unit cuboid centred on the origin. let cube: Solid = primitive::cuboid(BoundingBox::from_iter([ Point3::new(-0.5, -0.5, 0.0), Point3::new(0.5, 0.5, 1.0), ])); // Cylinder of radius 0.3, axis along +Z, that pierces the cube top to bottom. let seed = builder::vertex(Point3::new(0.3, 0.0, -0.1)) let rim = builder::revolve( &seed, Point3::new(0.0, 0.0, -0.1), Vector3::unit_z(), builder::SweepAngle::Closed, 4, ) let base = builder::try_attach_plane(&[rim])? let mut cylinder: Solid = builder::extrude(&base, Vector3::unit_z() * 1.2) // Invert the cylinder so `and` performs a subtraction. cylinder.not() let punched = solid::and(&cube, &cylinder, 0.05)? // Flatten the topology and render as STEP. let compressed = punched.compress() let step = CompleteStepDisplay::new( StepModel::from(&compressed), StepHeaderDescriptor { organization_system: "monstertruck-doc".to_owned(), ..Default::default() }, ) .to_string() assert!(step.starts_with("ISO-10303-21;")) assert!(step.contains("MANIFOLD_SOLID_BREP")) ``` -------------------------------- ### Subtract Cylinder from Box and Export STEP Source: https://docs.rs/monstertruck/0.3.2/monstertruck?search= This example demonstrates creating a cuboid and a cylinder, performing a boolean subtraction (cylinder from box), and exporting the resulting solid as a STEP file. Ensure necessary imports from monstertruck's modeling and step modules are included. ```rust use monstertruck::modeling::*; use monstertruck::solid; use monstertruck::step::save::{CompleteStepDisplay, StepHeaderDescriptor, StepModel}; // Unit cuboid centred on the origin. let cube: Solid = primitive::cuboid(BoundingBox::from_iter([ Point3::new(-0.5, -0.5, 0.0), Point3::new(0.5, 0.5, 1.0), ])); // Cylinder of radius 0.3, axis along +Z, that pierces the cube top to bottom. let seed = builder::vertex(Point3::new(0.3, 0.0, -0.1)); let rim = builder::revolve( &seed, Point3::new(0.0, 0.0, -0.1), Vector3::unit_z(), builder::SweepAngle::Closed, 4, ); let base = builder::try_attach_plane(&[rim])?; let mut cylinder: Solid = builder::extrude(&base, Vector3::unit_z() * 1.2); // Invert the cylinder so `and` performs a subtraction. cylinder.not(); let punched = solid::and(&cube, &cylinder, 0.05)?; // Flatten the topology and render as STEP. let compressed = punched.compress(); let step = CompleteStepDisplay::new( StepModel::from(&compressed), StepHeaderDescriptor { organization_system: "monstertruck-doc".to_owned(), ..Default::default() }, ) .to_string(); assert!(step.starts_with("ISO-10303-21;")); assert!(step.contains("MANIFOLD_SOLID_BREP")); ``` -------------------------------- ### Flatten and Render to STEP Source: https://docs.rs/monstertruck/0.3.2/src/monstertruck/lib.rs.html This snippet demonstrates how to flatten a topology, compress it, and then render it as a STEP file. It includes assertions to verify the output format and content. Ensure the `solid` and `step` features are enabled. ```rust //! let punched = solid::and(&cube, &cylinder, 0.05)?; //! //! // Flatten the topology and render as STEP. //! let compressed = punched.compress(); //! let step = CompleteStepDisplay::new( //! StepModel::from(&compressed), //! StepHeaderDescriptor { //! organization_system: "monstertruck-doc".to_owned(), //! ..Default::default() //! }, //! ) //! .to_string(); //! //! assert!(step.starts_with("ISO-10303-21;")); //! assert!(step.contains("MANIFOLD_SOLID_BREP")); //! # Ok(()) //! # } ``` -------------------------------- ### Flattening Topology and Rendering to STEP Source: https://docs.rs/monstertruck/0.3.2/src/monstertruck/lib.rs.html?search=u32+-%3E+bool This snippet demonstrates flattening a topology, compressing it, and then rendering it as a STEP file. It includes assertions to verify the output format and content. ```rust let punched = solid::and(&cube, &cylinder, 0.05)?; // Flatten the topology and render as STEP. let compressed = punched.compress(); let step = CompleteStepDisplay::new( StepModel::from(&compressed), StepHeaderDescriptor { organization_system: "monstertruck-doc".to_owned(), ..Default::default() }, ) .to_string(); assert!(step.starts_with("ISO-10303-21;")); assert!(step.contains("MANIFOLD_SOLID_BREP")); # Ok(()) # } ``` -------------------------------- ### Subtract Cylinder from Box and Export STEP Source: https://docs.rs/monstertruck/0.3.2/monstertruck?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates building a cuboid and a cylinder, performing a boolean subtraction, and exporting the resulting solid as a STEP file. Ensure necessary modules are imported. ```rust use monstertruck::modeling::*; use monstertruck::solid; use monstertruck::step::save::{CompleteStepDisplay, StepHeaderDescriptor, StepModel}; // Unit cuboid centred on the origin. let cube: Solid = primitive::cuboid(BoundingBox::from_iter([ Point3::new(-0.5, -0.5, 0.0), Point3::new(0.5, 0.5, 1.0), ])); // Cylinder of radius 0.3, axis along +Z, that pierces the cube top to bottom. let seed = builder::vertex(Point3::new(0.3, 0.0, -0.1)); let rim = builder::revolve( &seed, Point3::new(0.0, 0.0, -0.1), Vector3::unit_z(), builder::SweepAngle::Closed, 4, ); let base = builder::try_attach_plane(&[rim])?; let mut cylinder: Solid = builder::extrude(&base, Vector3::unit_z() * 1.2); // Invert the cylinder so `and` performs a subtraction. cylinder.not(); let punched = solid::and(&cube, &cylinder, 0.05)?; // Flatten the topology and render as STEP. let compressed = punched.compress(); let step = CompleteStepDisplay::new( StepModel::from(&compressed), StepHeaderDescriptor { organization_system: "monstertruck-doc".to_owned(), ..Default::default() }, ) .to_string(); assert!(step.starts_with("ISO-10303-21;")); assert!(step.contains("MANIFOLD_SOLID_BREP")); ``` -------------------------------- ### Subtract Cylinder from Box and Export STEP Source: https://docs.rs/monstertruck/0.3.2/monstertruck/index.html?search=std%3A%3Avec Builds a cuboid and a cylinder, subtracts the cylinder from the cuboid using a boolean AND operation with the inverted cylinder, and then exports the resulting solid as a STEP string. Requires the 'modeling' and 'step' sub-crates. ```rust use monstertruck::modeling::* use monstertruck::solid use monstertruck::step::save::{CompleteStepDisplay, StepHeaderDescriptor, StepModel}; // Unit cuboid centred on the origin. let cube: Solid = primitive::cuboid(BoundingBox::from_iter([ Point3::new(-0.5, -0.5, 0.0), Point3::new(0.5, 0.5, 1.0), ])); // Cylinder of radius 0.3, axis along +Z, that pierces the cube top to bottom. let seed = builder::vertex(Point3::new(0.3, 0.0, -0.1)); let rim = builder::revolve( &seed, Point3::new(0.0, 0.0, -0.1), Vector3::unit_z(), builder::SweepAngle::Closed, 4, ); let base = builder::try_attach_plane(&[rim])?; let mut cylinder: Solid = builder::extrude(&base, Vector3::unit_z() * 1.2); // Invert the cylinder so `and` performs a subtraction. cylinder.not(); let punched = solid::and(&cube, &cylinder, 0.05)?; // Flatten the topology and render as STEP. let compressed = punched.compress(); let step = CompleteStepDisplay::new( StepModel::from(&compressed), StepHeaderDescriptor { organization_system: "monstertruck-doc".to_owned(), ..Default::default() }, ) .to_string(); assert!(step.starts_with("ISO-10303-21;")); assert!(step.contains("MANIFOLD_SOLID_BREP")); ``` -------------------------------- ### Subtract Cylinder from Box and Export STEP Source: https://docs.rs/monstertruck/0.3.2/monstertruck?search=std%3A%3Avec Builds a cuboid and a cylinder, subtracts the cylinder from the cuboid using a boolean AND operation with the inverted cylinder, and then exports the resulting solid as a STEP string. Ensure necessary imports are present. ```rust use monstertruck::modeling::* use monstertruck::solid use monstertruck::step::save::{CompleteStepDisplay, StepHeaderDescriptor, StepModel} // Unit cuboid centred on the origin. let cube: Solid = primitive::cuboid(BoundingBox::from_iter([ Point3::new(-0.5, -0.5, 0.0), Point3::new(0.5, 0.5, 1.0), ])); // Cylinder of radius 0.3, axis along +Z, that pierces the cube top to bottom. let seed = builder::vertex(Point3::new(0.3, 0.0, -0.1)); let rim = builder::revolve( &seed, Point3::new(0.0, 0.0, -0.1), Vector3::unit_z(), builder::SweepAngle::Closed, 4, ); let base = builder::try_attach_plane(&[rim])?; let mut cylinder: Solid = builder::extrude(&base, Vector3::unit_z() * 1.2); // Invert the cylinder so `and` performs a subtraction. cylinder.not(); let punched = solid::and(&cube, &cylinder, 0.05)?; // Flatten the topology and render as STEP. let compressed = punched.compress(); let step = CompleteStepDisplay::new( StepModel::from(&compressed), StepHeaderDescriptor { organization_system: "monstertruck-doc".to_owned(), ..Default::default() }, ) .to_string(); assert!(step.starts_with("ISO-10303-21;")); assert!(step.contains("MANIFOLD_SOLID_BREP")); ``` -------------------------------- ### Add Monstertruck Dependency Source: https://docs.rs/monstertruck/0.3.2/monstertruck?search= Include the monstertruck crate in your project's Cargo.toml file. Use the 'full' feature flag to enable all functionalities except GPU and WASM glue. ```toml [dependencies] monstertruck = { version = "0.3", features = ["full"] } ``` -------------------------------- ### Monstertruck Feature Flags Source: https://docs.rs/monstertruck/0.3.2/src/monstertruck/lib.rs.html?search= This section outlines the feature flags available for the Monstertruck library's sub-crates. It details convenience groups like 'default' and 'full', and specific features such as 'rkyv', 'gpu', and 'wasm'. ```rust pub use monstertruck_core as core; #[cfg(feature = "traits")] pub use monstertruck_traits as traits; #[cfg(feature = "derive")] pub use monstertruck_derive as derive; #[cfg(feature = "geometry")] pub use monstertruck_geometry as geometry; #[cfg(feature = "topology")] pub use monstertruck_topology as topology; #[cfg(feature = "mesh")] pub use monstertruck_mesh as mesh; #[cfg(feature = "modeling")] pub use monstertruck_modeling as modeling; #[cfg(feature = "meshing")] pub use monstertruck_meshing as meshing; #[cfg(feature = "solid")] pub use monstertruck_solid as solid; #[cfg(feature = "assembly")] pub use monstertruck_assembly as assembly; #[cfg(feature = "step")] pub use monstertruck_step as step; #[cfg(feature = "gpu")] pub use monstertruck_gpu as gpu; #[cfg(feature = "render")] pub use monstertruck_render as render; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.