Skip to content
Permalink
Browse files

Created import_dxf to implement a simple geometry without brlcad

  • Loading branch information...
leonplust
leonplust committed Jun 4, 2019
1 parent ecd41db commit 2ae275728fceec3416190ecdcf4cc6140ead5ea5
Showing with 17 additions and 13 deletions.
  1. +1 −0 CMakeLists.txt
  2. +1 −0 openscad.pro
  3. +1 −2 src/import.cc
  4. +1 −0 src/import.h
  5. +12 −11 src/import_dxf.cc
  6. +1 −0 tests/CMakeLists.txt
@@ -328,6 +328,7 @@ set(NOCGAL_SOURCES
src/import_amf.cc
src/import_off.cc
src/import_svg.cc
src/import_dxf.cc
src/export.cc
src/export_3mf.cc
src/export_stl.cc
@@ -493,6 +493,7 @@ SOURCES += \
src/import_svg.cc \
src/import_amf.cc \
src/import_3mf.cc \
src/import_dxf.cc \
src/renderer.cc \
src/colormap.cc \
src/ThrownTogetherRenderer.cc \
@@ -169,8 +169,7 @@ const Geometry *ImportNode::createGeometry() const
break;
}
case ImportType::DXF: {
DxfData dd(this->fn, this->fs, this->fa, this->filename, this->layername, this->origin_x, this->origin_y, this->scale);
g = dd.toPolygon2d();
g = import_dxf(this->filename);
break;
}
#ifdef ENABLE_CGAL
@@ -5,6 +5,7 @@
class PolySet *import_stl(const std::string &filename);
PolySet *import_off(const std::string &filename);
class Polygon2d *import_svg(const std::string &filename);
class Polygon2d *import_dxf(const std::string &filename);
#ifdef ENABLE_CGAL
class CGAL_Nef_polyhedron *import_nef3(const std::string &filename);
#endif
@@ -3,33 +3,34 @@
#include "printutils.h"
#include "calc.h"
#include "Polygon2d.h"
#include "dxfdata.h"

Polygon2d *import_dxf(const std::string &filename)
{
//We now assume that brlcad can pass dxf data through this
//My thought is we may create a class for each entity to store the data?
// We now assume that brlcad can pass dxf data through this
// My thought is we may create a class for each entity to store the data?

//brlcad::entities_list *entities = brlcad::read_dxf_file(filename.c_str());
//Assume we have receive a data of square with a length of a 2.
// We should have somthing simiar to this.
// brlcad::entities_list *entities = brlcad::read_dxf_file(filename.c_str());
// Assume we have receive a data of square.

//To make it simple, I will ignore other enitities. Basically just use four
//lines to form the square
// To make it simple, I will ignore other enitities. Basically just use four
// lines to form the square

// These are other expected values that we should get from just the line entity
// std::string curr_layer_name
// std::string curr_color;
// double scale;

// Last extract data like coord from the entity
auto poly = new Polygon2d();
Grid2d<std::vector<int>> grid(GRID_COARSE);
std::vector<double> xCoord = {-1, -1, 1, -1};
std::vector<double> yCorrd = {-1, 1, 1, -1};
std::vector<double> xCoord = {-20, -20, 20, -20};
std::vector<double> yCorrd = {-20, 20, 20, -20};
int vertexNum = 4;
Outline2d outline;
for(size_t i = 0; i < vertexNum; i++){
for(int i = 0; i < vertexNum; i++){
grid.align(xCoord.at(i), yCorrd.at(i));
//what does the grid.align do?
//what does the grid.align do? Just align the vertex on the grid?
outline.vertices.push_back(Vector2d(xCoord.at(i),yCorrd.at(i)));
}
poly->addOutline(outline);
@@ -775,6 +775,7 @@ set(NOCGAL_SOURCES
../src/import_amf.cc
../src/import_off.cc
../src/import_svg.cc
../src/import_dxf.cc
../src/import_3mf.cc
../src/export.cc
../src/export_stl.cc

0 comments on commit 2ae2757

Please sign in to comment.
You can’t perform that action at this time.