Subject: CGAL users discussion list
List archive
[cgal-discuss] Re: Triangulation_3 compiler error C2143: syntax error: missing ';' before ')'
Chronological Thread
- From: cmodel <>
- To:
- Subject: [cgal-discuss] Re: Triangulation_3 compiler error C2143: syntax error: missing ';' before ')'
- Date: Thu, 24 Mar 2011 20:06:22 -0700 (PDT)
header file:
#ifndef POINT_SET_ITEM_H
#define POINT_SET_ITEM_H
#include "RS_scene_item_config.h"
#include "Polyhedron_type_fwd.h"
#include "Kernel_type.h"
#include "Point_set_3.h"
#include "Scene_item_with_display_list.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/Color.h>
#include <CGAL/Triangulation_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_2 Vb;
typedef CGAL::Triangulation_face_base_with_info_2<CGAL::Color,K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
typedef CGAL::Triangulation_2<K,Tds> Triangulation2;
typedef Triangulation2::Face_handle Face_handle2;
typedef Triangulation2::Point Point2;
typedef Triangulation2::Vertex_handle Vertex_handle2;
typedef Triangulation2::Locate_type Locate_type2;
typedef Triangulation2::Finite_faces_iterator Finite_faces_iterator2;
typedef Triangulation2::Finite_edges_iterator Finite_edges_iterator2;
typedef CGAL::Triangulation_vertex_base_with_info_3<CGAL::Color,K>
Vb3;
typedef CGAL::Triangulation_data_structure_3 Tds3;
typedef CGAL::Triangulation_3 Triangulation3;
typedef Triangulation3::Cell_handle Cell_handle3;
typedef Triangulation3::Vertex_handle Vertex_handle3;
typedef Triangulation3::Locate_type Locate_type3;
typedef Triangulation3::Point Point3;
typedef Triangulation3::Finite_cells_iterator Finite_cells_iterator3;
typedef Triangulation3::Finite_facets_iterator Finite_facets_iterator3;
typedef Triangulation3::Finite_edges_iterator Finite_edges_iterator3;
typedef Triangulation3::Finite_vertices_iterator Finite_vertices_iterator3;
typedef CGAL::Delaunay_triangulation_3<K,Tds3> Delaunay3;
typedef Delaunay3::Point DPoint3;
typedef Delaunay3::Vertex_handle DVertex_handle3;
typedef Delaunay3::Finite_cells_iterator DFinite_cells_iterator3;
// point set
typedef Point_set_3 Point_set;
typedef Point_set::UI_point UI_point; // type of points in Point_set_3
typedef struct _v_index { int a; int b; int c; } v_index;
// This class represents a point set in the OpenGL scene
class POINT_SET_ITEM_EXPORT RS_scene_item
: public Scene_item_with_display_list
{
Q_OBJECT
public:
RS_scene_item();
RS_scene_item(const RS_scene_item& toCopy);
RS_scene_item(const Polyhedron& p);
~RS_scene_item();
RS_scene_item* clone() const;
// Is selection empty?
virtual bool isSelectionEmpty() const;
// Delete selection
virtual void deleteSelection();
// Reset selection mark
void resetSelection();
// IO
bool read_off_point_set(std::istream& in);
bool write_off_point_set(std::ostream& out) const;
bool read_xyz_point_set(std::istream& in);
bool read_xyz_point_set2(std::istream& in);
bool write_xyz_point_set(std::ostream& out) const;
// Function for displaying meta-data of the item
virtual QString toolTip() const;
// Indicate if rendering mode is supported
virtual bool supportsRenderingMode(RenderingMode m) const;
// Points OpenGL drawing in a display list
virtual void direct_draw() const;
// Normals OpenGL drawing
virtual void draw_normals() const;
// Draws oriented points with radius
virtual void draw_splats() const;
// Gets wrapped point set
Point_set* point_set();
const Point_set* point_set() const;
// update point set container
bool add_point(UI_point pt) {m_points->push_back(pt); return true;}
bool set_point_set(Point_set * rhs) { m_points = rhs; return true;}
bool add_pt2(UI_point pt) { pts2->push_back(pt); return true;}
bool set_pt_cnt(std::vector * pts) { pt_cnt = pts; return true; }
// Gets dimensions
virtual bool isFinite() const { return true; }
virtual bool isEmpty() const;
virtual Bbox bbox() const;
virtual void setRenderingMode(RenderingMode m);
// computes the local point spacing (aka radius) of each point
void computes_local_spacing(int k);
public slots:
void onChange() {direct_draw();}
void onChangePoint(float a, float b, float c)
{
UI_point pt(a, b, c);
m_points->push_back(pt);
direct_draw();
}
// Data
private:
Point_set* m_points;
Point_set* pts2;
std::vector * pt_cnt;
Triangulation2 tr2;
Triangulation3 tr3;
Delaunay3 DT3;
std::vector * m_vindex3;
}; // end class RS_scene_item
#endif // POINT_SET_ITEM_H
cpp file:
#include "RS_scene_item.h"
#include "Polyhedron_type.h"
#include "CGAL/compute_normal.h"
#include <CGAL/IO/read_off_points.h>
#include <CGAL/IO/write_off_points.h>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/IO/write_xyz_points.h>
#include <CGAL/IO/io.h>
#include <CGAL/Timer.h>
#include <CGAL/Memory_sizer.h>
#include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/Search_traits_3.h>
#include
#include
#include
#include
#include
#include
#include
#include <boost/array.hpp>
typedef Point_set::Point_iterator P3_iterator;
RS_scene_item::RS_scene_item()
: Scene_item_with_display_list(),
m_points(new Point_set),pts2(new Point_set), pt_cnt(new std::vector),
m_vindex3(new std::vector)
{
setRenderingMode(Wireframe/*PointsPlusNormals*/);
}
// Copy constructor
RS_scene_item::RS_scene_item(const RS_scene_item& toCopy)
: Scene_item_with_display_list(), // do not call superclass' copy
constructor
m_points(new Point_set(*toCopy.m_points)),pts2(new Point_set),
pt_cnt(new std::vector), m_vindex3(new std::vector)
{
setRenderingMode(Wireframe/*PointsPlusNormals*/);
}
// Converts polyhedron to point set
RS_scene_item::RS_scene_item(const Polyhedron& input_mesh)
: Scene_item_with_display_list(),
m_points(new Point_set),pts2(new Point_set), pt_cnt(new std::vector),
m_vindex3(new std::vector)
{
// Converts Polyhedron vertices to point set.
// Computes vertices normal from connectivity.
Polyhedron::Vertex_const_iterator v;
for (v = input_mesh.vertices_begin(); v != input_mesh.vertices_end(); v++)
{
const Point& p = v->point();
Vector n = compute_vertex_normal<Polyhedron::Vertex,Kernel>(*v);
m_points->push_back(UI_point(p,n));pts2->push_back(UI_point(p,n));
}
setRenderingMode(Wireframe/*PointsPlusNormals*/);
}
RS_scene_item::~RS_scene_item()
{
Q_ASSERT(m_points != NULL);
delete m_points; m_points = NULL;
delete pts2; pts2 = NULL;
}
// Duplicates scene item
RS_scene_item*
RS_scene_item::clone() const
{
return new RS_scene_item(*this);
}
// Is selection empty?
bool RS_scene_item::isSelectionEmpty() const
{
return (m_points->nb_selected_points() == 0);
}
// Delete selection
void RS_scene_item::deleteSelection()
{
CGAL::Timer task_timer; task_timer.start();
std::cerr << "Delete " << m_points->nb_selected_points() << " points...";
// Delete selected points
m_points->delete_selection();
long memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "done: " << task_timer.time() << " seconds, "
<< (memory>>20) << " Mb allocated"
<< std::endl;
}
// Reset selection mark
void RS_scene_item::resetSelection()
{
// Un-select all points
m_points->select(m_points->begin(), m_points->end(), false);
}
// Loads point set from .OFF file
bool RS_scene_item::read_off_point_set(std::istream& stream)
{
Q_ASSERT(m_points != NULL);
m_points->clear();
bool ok = stream &&
CGAL::read_off_points_and_normals(stream,
std::back_inserter(*m_points),
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points)))
&&
!isEmpty();
return ok;
}
// Write point set to .OFF file
bool RS_scene_item::write_off_point_set(std::ostream& stream) const
{
Q_ASSERT(m_points != NULL);
return stream &&
CGAL::write_off_points_and_normals(stream,
m_points->begin(),
m_points->end(),
CGAL::make_normal_of_point_with_normal_pmap(m_points->begin()));
}
bool RS_scene_item::read_xyz_point_set2(std::istream& stream)
{
Q_ASSERT(m_points != NULL);
m_points->clear();
bool ok = stream &&
CGAL::read_xyz_points_and_normals(stream,
std::back_inserter(*m_points),
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points)))
&&
!isEmpty();
CGAL::Timer task_timer;
task_timer.start();
DT3.insert(m_points->begin(), m_points->end());
DT3.is_valid();
std::cout<<"number of vertices: " << DT3.number_of_vertices()
<<std::endl;
std::cout<<"number of faces: " <<
DT3.number_of_finite_facets() <<std::endl;
std::cout<<"number of cells: " <<
DT3.number_of_finite_cells() <<std::endl;
DFinite_cells_iterator3 dit = DT3.finite_cells_begin();
for(dit != DT3.finite_cells_end())
{
// how to get each Vertex_Handle from Cell_Iterator
// Can anyone help me ?
}
std::cout<< "total time : " << task_timer.time()
<< " seconds" <<std::endl;
return ok;
}
// Loads point set from .XYZ file
bool RS_scene_item::read_xyz_point_set(std::istream& stream)
{
Q_ASSERT(m_points != NULL);
m_points->clear();
bool ok = stream &&
CGAL::read_xyz_points_and_normals(stream,
std::back_inserter(*m_points),
CGAL::make_normal_of_point_with_normal_pmap(std::back_inserter(*m_points)))
&&
!isEmpty();
return ok;
}
// Write point set to .XYZ file
bool RS_scene_item::write_xyz_point_set(std::ostream& stream) const
{
Q_ASSERT(m_points != NULL);
return stream &&
CGAL::write_xyz_points_and_normals(stream,
m_points->begin(),
m_points->end(),
CGAL::make_normal_of_point_with_normal_pmap(m_points->begin()));
}
QString
RS_scene_item::toolTip() const
{
Q_ASSERT(m_points != NULL);
return QObject::tr("
%1 (color: %4)
"
"Point set
"
"
Number of points: %2
")
.arg(name())
.arg(m_points->size())
.arg(color().name());
}
bool RS_scene_item::supportsRenderingMode(RenderingMode m) const
{
//return m==Points || m==PointsPlusNormals || m==Splatting;
return m==Points || m==Wireframe || m==Gouraud;
}
// Points OpenGL drawing in a display list
void RS_scene_item::direct_draw() const
{
Q_ASSERT(m_points != NULL);
// Draw points
m_points->gl_draw_vertices();
}
// Normals OpenGL drawing
void RS_scene_item::draw_normals() const
{
Q_ASSERT(m_points != NULL);
// Draw normals
bool points_have_normals = (m_points->begin() != m_points->end() &&
m_points->begin()->normal() !=
CGAL::NULL_VECTOR);
if(points_have_normals)
{
Sphere region_of_interest = m_points->region_of_interest();
float normal_length =
(float)std::sqrt(region_of_interest.squared_radius() / 1000.);
m_points->gl_draw_normals(normal_length);
}
}
void RS_scene_item::draw_splats() const
{
Q_ASSERT(m_points != NULL);
// Draw splats
bool points_have_normals = (m_points->begin() != m_points->end() &&
m_points->begin()->normal() !=
CGAL::NULL_VECTOR);
bool points_have_radii = (m_points->begin() != m_points->end() &&
m_points->begin()->radius() != FT(0));
if(points_have_normals && points_have_radii)
{
m_points->gl_draw_splats();
}
}
// Gets wrapped point set
Point_set* RS_scene_item::point_set()
{
Q_ASSERT(m_points != NULL);
return m_points;
}
const Point_set* RS_scene_item::point_set() const
{
Q_ASSERT(m_points != NULL);
return m_points;
}
bool
RS_scene_item::isEmpty() const
{
Q_ASSERT(m_points != NULL);
return m_points->empty();
}
RS_scene_item::Bbox
RS_scene_item::bbox() const
{
Q_ASSERT(m_points != NULL);
Iso_cuboid bbox = m_points->bounding_box();
return Bbox(bbox.xmin(),bbox.ymin(),bbox.zmin(),
bbox.xmax(),bbox.ymax(),bbox.zmax());
}
void RS_scene_item::computes_local_spacing(int k)
{
typedef Kernel Geom_traits;
typedef Geom_traits::FT FT;
typedef CGAL::Search_traits_3 TreeTraits;
typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search;
typedef Neighbor_search::Tree Tree;
Point_set::iterator end(m_points->end());
// build kdtree
Tree tree(m_points->begin(), end);
// Compute the radius of each point = (distance max to k nearest
neighbors)/2.
{
int i=0;
for (Point_set::iterator it=m_points->begin(); it!=end; ++it, ++i)
{
Neighbor_search search(tree, *it, k+1);
double maxdist2 = search.begin()->second; // squared distance to
furthest neighbor
it->radius() = sqrt(maxdist2)/2.;
}
}
m_points->set_radii_uptodate(true);
}
void RS_scene_item::setRenderingMode(RenderingMode m)
{
Scene_item_with_display_list::setRenderingMode(m);
if (rendering_mode==Splatting && (!m_points->are_radii_uptodate()))
{
computes_local_spacing(6); // default value = small
}
}
#include "RS_scene_item.moc"
http://cgal-discuss.949826.n4.nabble.com/file/n3404346/cmodel_rs_scene_item.h
cmodel_rs_scene_item.h
http://cgal-discuss.949826.n4.nabble.com/file/n3404346/cmodel_rs_scene_item.cpp
cmodel_rs_scene_item.cpp
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Triangulation-3-compiler-error-C2143-syntax-error-missing-before-tp3402829p3404346.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Triangulation_3 compiler error C2143: syntax error: missing ';' before ')', cmodel, 03/24/2011
- Re: [cgal-discuss] Triangulation_3 compiler error C2143: syntax error: missing ';' before ')', Sebastien Loriot (GeometryFactory), 03/24/2011
- [cgal-discuss] Re: Triangulation_3 compiler error C2143: syntax error: missing ';' before ')', cmodel, 03/25/2011
- [cgal-discuss] Re: Triangulation_3 compiler error C2143: syntax error: missing ';' before ')', cmodel, 03/25/2011
- Re: [cgal-discuss] Re: Triangulation_3 compiler error C2143: syntax error: missing ';' before ')', Sebastien Loriot (GeometryFactory), 03/25/2011
- [cgal-discuss] Re: Triangulation_3 compiler error C2143: syntax error: missing ';' before ')', cmodel, 03/25/2011
- [cgal-discuss] Re: Triangulation_3 compiler error C2143: syntax error: missing ';' before ')', cmodel, 03/25/2011
- Re: [cgal-discuss] Triangulation_3 compiler error C2143: syntax error: missing ';' before ')', Sebastien Loriot (GeometryFactory), 03/24/2011
Archive powered by MHonArc 2.6.16.