Personal tools
You are here: Home Courses 3d Printing Assignments Assignment 1 Additional Information
« August 2019 »
August
SuMoTuWeThFrSa
123
45678910
11121314151617
18192021222324
25262728293031
Log in


Forgot your password?
 

Assignment 1 Additional Information

Exercise 1.1

General

Your solution to exercise 1.1 should consist of some source files and a pdf file called find_print_direction_2d.pdf that describes the implemented algorithm.

You may write the code in the following programming languages: C++, C, Java, Python, or Perl. If you want to write in a different language, I'll probably allow it, but please talk to me first.

If you develop in Jave, Perl, or Python provide a source code file, namely  find_print_direction_2d.java (Java) find_print_direction_2d.pl(Perl), or find_print_direction_2d.py (Python) and list in the documentation what special modules must be installed, if any.

If the code is written in C++ (resp. C), provide one source file called find_ptint_direction_2d.cpp (resp. find_ptint_direction_2d.c), and CMakeLists.txt (input to cmake). Running cmake on the provided CMakeLists.txt followed by compilation and linkage should produce an executable called find_print_direction_2d. You do not have to use CGAL for this exercise. However, if you want your program to be efficient and robust at the same time, and prepare yorself for the coming exercises, you are welcome. If you decide to use CGAL and place the source file in a dedicated directory that does not contain anything else, you can simply run:

<CGAL>/Scripts/scripts/cgal_create_cmake_script example

to generate CMakeLists.txt, where <CGAL> is the directory where CGAL was installed from sources at. If you want to use C++11 features, edit the generated CMakeLists.txt file, and add the following lines:

  if (CMAKE_COMPILER_IS_GNUCXX)
    add_definitions(-std=c++11)
  endif()

You can develop on any platform, but the code must compile and run using g++ on Linux.

The program find_print_direction_2d accepts two arguments on the command line, namely, the width of the printer as a rational number and the name of the file that contains the input polygon. By default, the file is called polygon.txt. A rational number is given either as a decimal number or as a numerator and denominator separated by '/' (e.g., 1/3), where the numerator and denominator are both unlimited integers.

Input & Output

The input file that contains the polygon description is a text file (as its extension suggests). It consists of the number of points on the polygon boundary followed by the points listed in counterclockwise orientation.

n x0 y0 x1 y1 ... xn-1 yn-1

n is an integral number and each point is given by its x and y coordinates, which are rational numbers.

The program computes a rotation. You are given two options to represent the rotation:

  1. An angle in radians that one needs to rotate the polygon counterclockwise in order to put it in the printer at a minimal-height position.
  2. A (not necessarily normalized) direction in the plane, which is the up vector (0,1) rotated together with the polygon so that it ends up at a minimal-height position.

The program should export a line of text to the standard output stream.

If the width of the polygon is larger than the given width of the printer, there is no solution. In this case export the following line:

The polygon cannot be printed, because it is two wide (<width>)!

where <width> is the width of the polygon.

Otherwise, export either the line:

Angle <angle>

where <angle> is a decimal number, or the line:

Direction <x> <y>

where <x> and <y> are rational numbers.

When developing code that follows the Exact Geometric Paradigm (such as the code of CGAL) it makes more sense to represent the rotation using a direction rather using an angle, but in this exercise you are given the freedom to choose.

Installation and Assistance

You can obtain the latest CGAL public release from here.

The CGAL installation manual is available here.

Further detailed instructions for installing CGAL on Windows is available here. This is a bit outdated though.

Ipe is a drawing editor for creating figures in PDF or (encapsulated) Postscript format.

This is an example of a CMakeLists.txt file produced produced by the cgal_create_cmake_script script.

Exercise 1.2

In this exercise you are required to apply a uniform scale to a polyhedron in the stl format. There are two stl formats, namely a binary one and a textual one. You can choose which one to use (based on the polyhedron you have decided to print.) Develop a small program that accepts a file in the stl format and a scale factor; then, it scales the input polyhedron, and saves the scaled polyhedron in the stl format in an output file. Please provide the source code of your small program. Also, take a photo of your printed object and add its picture to the submitted material. Indicate the source of the model. Optionally, list any piece of information that might be relevant (not necessary to the grade, but to the benefit of us all using the 3D printer), such as how many times have you attempted to print it and what were the reasons for the failures, if any.

The type of filament installed on head 1 is PLA; its diameter is 1.75 mm. You need to configure Cura accordingly. This filament is not recognized by the printer, so the printer will not verify the correctness of your settings.

The type of filament installed on head 2 is PVA. It is recognized by the printer. Also, specify any other piece of information that might be relevant (not necessary to the grade, but to the benefit of us all using the printer).

Q&A

  • Can I use MATLAB?
    • Yes, for this exercise almost everything is accepted. However, you will have to come by and demonstrate it in person, preferably on your laptop.

  • Can I use Java?
    • Yes, I've added to Java to the official accepted dev. languages.

  • I develop in Perl or Python, what exactly do I have to submit?
    • Send the source code file, namely find_print_direction_2d.pl(Perl) or find_print_direction_2d.py (Python) and list in the documentation what special modules must be installed, if any.

  • What exactly do I need to submit for Exercise 1.2 (except for the code)?
    • Please take a photo and attach it as well. Indicate the source of your model. Optionally, list any piece of information that might be relevant (not necessary to the grade, but to the benefit of us all using the printer), such as how many times have you attempted to print it and what were the reasons for the failures, if any.

  • What if the width of the polygon exceeds the given width of the printer?
    • Export the line:
      The polygon cannot be printed, because it is two wide (<width>)!
      where <width> is the width of the polygon.

  • What exactly do we need to produce as part of the graphic results of Exercise 1.1?
    • It is optional. It was suggested as a way for students to visualize the input and output polygons as an aid while developing the code. "
    • ipe is nice standalone application that can be used to visualize 2D geometric objects. It can read text file (in some xml format). You can edit the displayed objects (e.g., polygons) via a textual windows (using the "Edit as XML" menu option).

  • I am trying to apply a rotation using CGAL and I am having some difficulties.
    • There is no way to represent the sin and cos of an angle as exact numbers, cause they are not even algebraic. In simple words, if you start with an angle or even a vector, you cannot obtain an exact transformation matrix. An angle of rotation cannot be obtained in an exact manner using vector arithmetic. The best you can do is obtain an approximation of the rotation, while bounding the error.

      In CGAL there is a construction of an object of type CGAL/Aff_transformation_2.h that accepts a vector that represents the rotation. It constructs an approximation; see http://doc.cgal.org/latest/Kernel_23/classCGAL_1_1Aff__transformation__2.html#a5cc6631b0ed023470ccfc9e37e5272fb
Document Actions