// Copyright (c) 2005 INRIA Sophia-Antipolis (France). // All rights reserved. // // This file is part of CGAL (www.cgal.org); you may redistribute it under // the terms of the Q Public License version 1.0. // See the file LICENSE.QPL distributed with CGAL. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // // // Author(s) : Laurent Rineau #ifndef SOMMET #define SOMMET #include #include #include #include #include #include #include #include #include #include #include "Constrained_Element.h" #include "Constrained_Facet.h" #include "Constrained_Edge.h" CGAL_BEGIN_NAMESPACE template class Constrained_Vertex : public virtual Constrained_Element { public : typedef Gt Geom_traits; typedef typename Gt::FT Nb; typedef typename Gt::Point_3 Point; typedef typename Gt::Vector_3 Vector; typedef typename Gt::Segment_3 Segment; typedef typename Gt::Iso_cuboid_3 Iso_Cuboid; typedef typename Gt::Triangle_3 Triangle; typedef typename Gt::Plane_3 Plane; typedef typename Gt::Tetrahedron_3 Tetrahedron; typedef typename Gt::Line_3 Line; typedef typename Gt::Object_3 Object; typedef typename Gt::Ray_3 Ray; typedef CGAL :: Bbox_3 Bbox_3; typedef Constrained_Element C_elt; typedef Constrained_Facet C_facet; typedef Constrained_Edge C_edge; typedef Constrained_Vertex C_vertex; private : Point p; int num; Geom_traits gt; public : //constructeur Constrained_Vertex(void) : C_elt("vertex"){} Constrained_Vertex(Point pt) : C_elt("vertex"), p(pt) { } //Declaration Des Fonctions Bbox_3 getBBox(); Point point(); bool does_intersect( Iso_Cuboid c); bool does_intersect( Tetrahedron tet); bool does_intersect( Segment seg ); bool does_intersect( C_elt* ce); bool does_intersect( Ray ray ); bool does_intersect_vertex( Constrained_Vertex* s); bool does_intersect_edge( C_edge* a); bool does_intersect_facet( C_facet* f); bool operator== (Constrained_Vertex s); bool operator!= (Constrained_Vertex s); Nb sqared_distance_to_sheet(Point q); Object intersection (Segment seg); Object intersection (Ray ray); }; //------------------------------------------------------------------- template bool Constrained_Vertex ::operator== (Constrained_Vertex s){ typename Geom_traits::Equal_3 equal_3 = gt.equal_3_object(); return ((equal_3(p,s.point()) ) && (p,s.getNum())); } //------------------------------------------------------------------- template bool Constrained_Vertex ::operator!= (Constrained_Vertex s){ typename Geom_traits::Equal_3 equal_3 = gt.equal_3_object(); return !((equal_3(p,s.point()) ) && (p,s.getNum())); } //------------------------------------------------------------------- // fonction qui retourne la bounding box de la contrainte template typename Constrained_Vertex :: Bbox_3 Constrained_Vertex :: getBBox() { // ???????? return p.bbox(); //commande CGAL //return construct_bbox_3(this.p); } //------------------------------------------------------------------- // fonction qui retourne la bounding boxe Point template typename Constrained_Vertex :: Point Constrained_Vertex :: point() { // ???????? return p; } //------------------------------------------------------------------- //fonction qui retourne true si la contrainte intersecte un //isocuboide donne C template bool Constrained_Vertex :: does_intersect( Iso_Cuboid c) { typename Geom_traits:: Has_on_bounded_side_3 has_on_bounded_side =gt.has_on_bounded_side_3_object(); typename Geom_traits:: Has_on_boundary_3 has_on_boundary =gt.has_on_boundary_3_object(); //std :: cerr<< "Vertex does_intersect " // << ( (has_on_bounded_side(c,p)) || (has_on_boundary(c,p))) < bool Constrained_Vertex ::does_intersect( Tetrahedron tet){ typename Geom_traits:: Has_on_bounded_side_3 has_on_bounded_side =gt.has_on_bounded_side_3_object(); typename Geom_traits:: Has_on_boundary_3 has_on_boundary =gt.has_on_boundary_3_object(); return ( (has_on_bounded_side(tet,p)) || (has_on_boundary(tet,p))); } //------------------------------------------------------------------- //fonction qui retourne true si la contrainte intersecte une //une ligne donnee template bool Constrained_Vertex ::does_intersect(Segment seg){ typename Geom_traits:: Has_on_3 has_on =gt.has_on_3_object(); return ( has_on(seg,p)); } //------------------------------------------------------------------- //fonction qui retourne true si la contrainte intersecte une //une ligne donnee template bool Constrained_Vertex ::does_intersect(Ray ray){ typename Geom_traits:: Has_on_3 has_on =gt.has_on_3_object(); return ( has_on(ray,p)); } //------------------------------------------------------------------- template bool Constrained_Vertex :: does_intersect_vertex(Constrained_Vertex* s) { typename Geom_traits:: Equal_3 equal_3 = gt.equal_3_object(); typename Geom_traits::Construct_vertex_3 construct_vertex = gt.construct_vertex_3_object(); //std::cerr<<"le point : "<point()) ) ; } //------------------------------------------------------------------- template bool Constrained_Vertex :: does_intersect_edge(C_edge* a) { typename Geom_traits:: Equal_3 equal_3 = gt.equal_3_object(); typename Geom_traits::Construct_vertex_3 construct_vertex = gt.construct_vertex_3_object(); Point pp = construct_vertex(a->s,0), q = construct_vertex(a->s,1); //std::cerr<<"le point : "<s< bool Constrained_Vertex :: does_intersect_facet( C_facet* facet ) { typename Geom_traits::Construct_vertex_3 construct_vertex = gt.construct_vertex_3_object(); typename Geom_traits:: Equal_3 equal_3 = gt.equal_3_object(); Triangle t = facet->getTriangle(); Point r; for(int i=0;i<3;i++) { r = construct_vertex(t,i); if (equal_3(r,p)) return true; } // ne pas oublier de l'effacetr //std::cerr< bool Constrained_Vertex :: does_intersect( C_elt* ce) { char* type = ce->getType(); if ((strcmp(type,"vertex") == 0)) return does_intersect_vertex(dynamic_cast(ce) ); else if ((strcmp(type,"edge") == 0)) return does_intersect_edge(dynamic_cast(ce) ); else return does_intersect_facet(dynamic_cast(ce) ); } //------------------------------------------------------------------- template typename Constrained_Vertex ::Nb Constrained_Vertex :: sqared_distance_to_sheet(Point q) { typename Geom_traits:: Compute_squared_distance_3 compute_squared_distance = gt.compute_squared_distance_3_object(); //std::cerr<<"sommet : "< typename Constrained_Vertex :: Object Constrained_Vertex :: intersection (Segment seg) { return Object(); } template typename Constrained_Vertex :: Object Constrained_Vertex :: intersection (Ray ray) { return Object(); } CGAL_END_NAMESPACE #endif