Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Created by https://www.gitignore.io/api/vim,git,c++,linux
# Edit at https://www.gitignore.io/?templates=vim,git,c++,linux

### C++ ###
# Prerequisites
*.d

Expand All @@ -23,8 +27,63 @@
# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim

# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

# End of https://www.gitignore.io/api/vim,git,c++,linux

Dependencies
acd2d_gui
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
-s save decomposition when OpenGL GUI is disabled
-ps save decomposition to postscript (PS) file (when GUI is disabled)

see [POLY\_FORMAT.txt](test_env/POLY_FORMAT.txt) for description of .poly file specifications.

### GUI options (press key):

d: decompose once
Expand Down
5 changes: 4 additions & 1 deletion src/acd2d_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ namespace acd2d
//cut into two polys
pair<cd_polygon,cd_polygon> sub_polys;
cd_diagonal dia=cutPolys(sub_polys,polys.front(),cut_l);

sub_polys.first.cur_scale = polys.cur_scale;
sub_polys.second.cur_scale = polys.cur_scale;

//add into to do
todo_list.push_back(sub_polys.first);
Expand Down Expand Up @@ -140,4 +143,4 @@ namespace acd2d
if(store_diagoanls) dia_list.push_back(dia);
}

}//namespace acd2d
}//namespace acd2d
9 changes: 9 additions & 0 deletions src/acd2d_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,15 @@ namespace acd2d
void cd_polygon::normalize()
{
float r=front().getRadius();
cur_scale /= r;
scale(1.0/r);
}

void cd_polygon::unnormalize()
{
scale(1.0 / cur_scale);
cur_scale = 1.0;
}

bool cd_polygon::valid() const //check if this is a valid polygon
{
Expand All @@ -585,6 +592,8 @@ namespace acd2d
p.copy(*i);
push_back(p);
}

cur_scale = other.cur_scale;
}

void cd_polygon::destroy()
Expand Down
6 changes: 6 additions & 0 deletions src/acd2d_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ namespace acd2d
cd_poly& outmost();
void scale(float factor);
void normalize();
void unnormalize();
bool valid() const; //check if this is a valid polygon
void copy(const cd_polygon& other);
void destroy();
Expand Down Expand Up @@ -260,6 +261,11 @@ namespace acd2d
typedef list<Dep_El*> DEL;
typedef DEL::iterator DIT;
DEL m_DependList; //this decides the order of dependency

// Store global scale information for post-decomposition recovery

public:
float cur_scale=1.0;
};

///////////////////////////////////////////////////////////////////////////////
Expand Down
14 changes: 11 additions & 3 deletions src/acd2d_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,16 @@ namespace acd2d
inline void save_polys(ostream& fout, const list<cd_polygon>& polys)
{
typedef list<cd_polygon>::const_iterator PIT;
for( PIT ip=polys.begin();ip!=polys.end();ip++ ) //for each poly
fout<<*ip;
for( PIT ip=polys.begin();ip!=polys.end();ip++ ){ //for each poly
// save normalized version
// fout<<*ip;

// save decomposition at original scale
cd_polygon p;
p.copy(*ip);
p.unnormalize();
fout << p;
}
}

inline void save_polys(const string& name, const cd_2d& cd)
Expand Down Expand Up @@ -170,7 +178,7 @@ namespace acd2d
box[1]=box[3]=-FLT_MAX;

for( POIT i=polys.begin();i!=polys.end();i++ ){
for(PIT j=i->begin();j!=i->end();j++){
for(PIT j=i->begin();j!=i->end();j++){
double B[4];
polyBox(*j,B);

Expand Down