1
0
Fork 0

Modifications to facilitate conversion to output format.

This commit is contained in:
curt 1999-03-22 23:49:01 +00:00
parent b8c705fb28
commit 4c1565c869
5 changed files with 63 additions and 6 deletions

View file

@ -2,6 +2,7 @@ noinst_LIBRARIES = libTriangulate.a
libTriangulate_a_SOURCES = \ libTriangulate_a_SOURCES = \
triangle.cxx triangle.hxx \ triangle.cxx triangle.hxx \
trieles.cxx trieles.hxx \
trinodes.cxx trinodes.hxx \ trinodes.cxx trinodes.hxx \
tripoly.cxx tripoly.hxx \ tripoly.cxx tripoly.hxx \
trisegs.cxx trisegs.hxx trisegs.cxx trisegs.hxx

View file

@ -57,7 +57,7 @@ FGTriangle::build( const fitnode_list& fit_list,
f_current = fit_list.begin(); f_current = fit_list.begin();
f_last = fit_list.end(); f_last = fit_list.end();
for ( ; f_current != f_last; ++f_current ) { for ( ; f_current != f_last; ++f_current ) {
index = trinodes.unique_add( *f_current ); index = in_nodes.unique_add( *f_current );
} }
gpc_polygon *gpc_poly; gpc_polygon *gpc_poly;
@ -97,8 +97,8 @@ FGTriangle::build( const fitnode_list& fit_list,
Point3D p( gpc_poly->contour[j].vertex[k].x, Point3D p( gpc_poly->contour[j].vertex[k].x,
gpc_poly->contour[j].vertex[k].y, gpc_poly->contour[j].vertex[k].y,
0 ); 0 );
index = trinodes.unique_add( p ); index = in_nodes.unique_add( p );
// junkp = trinodes.get_node( index ); // junkp = in_nodes.get_node( index );
// fprintf(junkfp, "%.4f %.4f\n", junkp.x(), junkp.y()); // fprintf(junkfp, "%.4f %.4f\n", junkp.x(), junkp.y());
poly.add_node(index); poly.add_node(index);
// cout << index << endl; // cout << index << endl;
@ -108,7 +108,7 @@ FGTriangle::build( const fitnode_list& fit_list,
// gpc_poly->contour[j].vertex[0].y); // gpc_poly->contour[j].vertex[0].y);
// fclose(junkfp); // fclose(junkfp);
poly.calc_point_inside( trinodes ); poly.calc_point_inside( in_nodes );
polylist[i].push_back(poly); polylist[i].push_back(poly);
} }
@ -208,7 +208,7 @@ int FGTriangle::run_triangulate() {
int counter; int counter;
// point list // point list
trinode_list node_list = trinodes.get_node_list(); trinode_list node_list = in_nodes.get_node_list();
in.numberofpoints = node_list.size(); in.numberofpoints = node_list.size();
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL)); in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
@ -241,6 +241,7 @@ int FGTriangle::run_triangulate() {
triseg_list seg_list = trisegs.get_seg_list(); triseg_list seg_list = trisegs.get_seg_list();
in.numberofsegments = seg_list.size(); in.numberofsegments = seg_list.size();
in.segmentlist = (int *) malloc(in.numberofsegments * 2 * sizeof(int)); in.segmentlist = (int *) malloc(in.numberofsegments * 2 * sizeof(int));
in.segmentmarkerlist = (int *) NULL;
triseg_list_iterator s_current, s_last; triseg_list_iterator s_current, s_last;
s_current = seg_list.begin(); s_current = seg_list.begin();
@ -323,6 +324,27 @@ int FGTriangle::run_triangulate() {
// TEMPORARY // TEMPORARY
write_out_data(&out); write_out_data(&out);
// now copy the results back into the corresponding FGTriangle
// structures
// nodes
for ( int i = 0; i < out.numberofpoints; i++ ) {
Point3D p( out.pointlist[2*i], out.pointlist[2*i + 1], 0.0 );
// cout << "point = " << p << endl;
out_nodes.simple_add( p );
}
// triangles
int n1, n2, n3;
for ( int i = 0; i < out.numberoftriangles; i++ ) {
n1 = out.trianglelist[i * 3];
n2 = out.trianglelist[i * 3 + 1];
n3 = out.trianglelist[i * 3 + 2];
// cout << "triangle = " << n1 << " " << n2 << " " << n3 << endl;
elelist.push_back( FGTriEle( n1, n2, n3 ) );
}
// free mem allocated to the "Triangle" structures // free mem allocated to the "Triangle" structures
free(in.pointlist); free(in.pointlist);
free(in.pointattributelist); free(in.pointattributelist);
@ -349,6 +371,9 @@ int FGTriangle::run_triangulate() {
// $Log$ // $Log$
// Revision 1.10 1999/03/22 23:49:02 curt
// Modifications to facilitate conversion to output format.
//
// Revision 1.9 1999/03/21 15:48:02 curt // Revision 1.9 1999/03/21 15:48:02 curt
// Removed Dem2node from the Tools fold. // Removed Dem2node from the Tools fold.
// Tweaked the triangulator options to add quality mesh refinement. // Tweaked the triangulator options to add quality mesh refinement.

View file

@ -45,6 +45,7 @@ extern "C" {
#include <Triangle/triangle.h> #include <Triangle/triangle.h>
} }
#include "trieles.hxx"
#include "trinodes.hxx" #include "trinodes.hxx"
#include "tripoly.hxx" #include "tripoly.hxx"
#include "trisegs.hxx" #include "trisegs.hxx"
@ -56,13 +57,18 @@ typedef vector < FGTriPoly > tripoly_list;
typedef tripoly_list::iterator tripoly_list_iterator; typedef tripoly_list::iterator tripoly_list_iterator;
typedef tripoly_list::const_iterator const_tripoly_list_iterator; typedef tripoly_list::const_iterator const_tripoly_list_iterator;
typedef vector < FGTriEle > triele_list;
typedef triele_list::iterator triele_list_iterator;
typedef triele_list::const_iterator const_triele_list_iterator;
class FGTriangle { class FGTriangle {
private: private:
// list of nodes // list of nodes
FGTriNodes trinodes; FGTriNodes in_nodes;
FGTriNodes out_nodes;
// list of segments // list of segments
FGTriSegments trisegs; FGTriSegments trisegs;
@ -70,6 +76,9 @@ private:
// polygon list // polygon list
tripoly_list polylist[FG_MAX_AREA_TYPES]; tripoly_list polylist[FG_MAX_AREA_TYPES];
// triangle list
triele_list elelist;
public: public:
// Constructor and destructor // Constructor and destructor
@ -84,6 +93,8 @@ public:
// front end triangulator for polygon list // front end triangulator for polygon list
int run_triangulate(); int run_triangulate();
inline FGTriNodes get_out_nodes() const { return out_nodes; }
}; };
@ -91,6 +102,9 @@ public:
// $Log$ // $Log$
// Revision 1.7 1999/03/22 23:49:03 curt
// Modifications to facilitate conversion to output format.
//
// Revision 1.6 1999/03/20 20:32:56 curt // Revision 1.6 1999/03/20 20:32:56 curt
// First mostly successful tile triangulation works. There's plenty of tweaking // First mostly successful tile triangulation works. There's plenty of tweaking
// to do, but we are marching in the right direction. // to do, but we are marching in the right direction.

View file

@ -74,7 +74,18 @@ int FGTriNodes::unique_add( const Point3D& p ) {
} }
// Add the point with no uniqueness checking
int FGTriNodes::simple_add( const Point3D& p ) {
node_list.push_back( p );
return node_list.size() - 1;
}
// $Log$ // $Log$
// Revision 1.4 1999/03/22 23:49:04 curt
// Modifications to facilitate conversion to output format.
//
// Revision 1.3 1999/03/20 02:21:54 curt // Revision 1.3 1999/03/20 02:21:54 curt
// Continue shaping the code towards triangulation bliss. Added code to // Continue shaping the code towards triangulation bliss. Added code to
// calculate some point guaranteed to be inside a polygon. // calculate some point guaranteed to be inside a polygon.

View file

@ -68,6 +68,9 @@ public:
// Returns the index (starting at zero) of the point in the list. // Returns the index (starting at zero) of the point in the list.
int unique_add( const Point3D& p ); int unique_add( const Point3D& p );
// Add the point with no uniqueness checking
int simple_add( const Point3D& p );
// return the master node list // return the master node list
inline trinode_list get_node_list() const { return node_list; } inline trinode_list get_node_list() const { return node_list; }
@ -80,6 +83,9 @@ public:
// $Log$ // $Log$
// Revision 1.4 1999/03/22 23:49:05 curt
// Modifications to facilitate conversion to output format.
//
// Revision 1.3 1999/03/20 02:21:55 curt // Revision 1.3 1999/03/20 02:21:55 curt
// Continue shaping the code towards triangulation bliss. Added code to // Continue shaping the code towards triangulation bliss. Added code to
// calculate some point guaranteed to be inside a polygon. // calculate some point guaranteed to be inside a polygon.