Computer-aided design - Importing IGES and STEP files

From Medusa: Coordinate Free Mehless Method implementation
Jump to: navigation, search

Go back to Examples.

STEP and IGES files can be directly translated into Medusa's NURBSShape if they only contain NURBS objects. Helper functions, which do that, are provided in the Medusa-Extras repository. For their usage, OpenCASCADE library must be installed on the system.

Some example CAD models are also provided in the repository, code that discretizes a tiger model using the strategy described in Determining the interior of the domain by oversampling the boundary is shown below

 1 NURBSShape<Vec3d, Vec2d> shape = translate_STEP("examples/tiger.step");
 2 double h = 2;
 3 
 4 // Oversample the domain.
 5 DomainDiscretization<Vec3d> oversampled_domain = shape.discretizeBoundaryWithStep(h / 5);
 6 
 7 for (int i = 0; i < oversampled_domain.size(); i++) {
 8     oversampled_domain.normal(i) *= -1;
 9 }
10 
11 // Construct the contains function.
12 KDTree<Vec3d> contains_tree;
13 oversampled_domain.makeDiscreteContainsStructure(contains_tree);
14 auto contains_function = [&] (const Vec3d p) {
15     return oversampled_domain.discreteContains(p, contains_tree);
16 };
17 
18 // Fill the boundary normally.
19 DomainDiscretization<Vec3d> domain = shape.discretizeBoundaryWithStep(h);
20 
21 // Fill the interior with the contains function.
22 KDTreeMutable<Vec3d> tree;
23 GeneralFill<Vec3d> gf;
24 gf(domain, h, tree, contains_function);

Using the provided plot script, we get

Tiger.png