Exemplo n.º 1
0
Halfedge_handle DegradeAnObject::splitFacet(Facet fs, int index) {
	Halfedge_handle hh1 = fs.halfedge();
	Halfedge_handle hh2 = fs.halfedge()->next();
	Halfedge_handle hh3 = fs.halfedge()->next()->next();
	splitEdgesOfFacet(fs, index);
	Halfedge_handle h = barycentricMesh(fs, index);
	noTVertice(hh1, hh2, hh3, index);
	return h;
}
Exemplo n.º 2
0
Halfedge_handle DegradeAnObject::barycentricMesh(Facet fs, int index) {
	std::vector<Point_3> points;
	Halfedge_handle hh = fs.halfedge();
	Point_3 p1 = hh->vertex()->point();
	points.push_back(p1);
	hh = hh->next();
	while(hh->vertex()->point() != p1) {
		points.push_back(hh->vertex()->point());
		hh = hh->next();
	}
	Halfedge_handle h = polys[index].create_center_vertex(fs.halfedge());
	h->vertex()->point() = meanPoints(points);
	return h;
}
// Constructs HDS for a pane from element connectivity array.
void 
RFC_Pane_overlay::build_hds() {
  RFC_assertion( _base);
  if ( _base->size_of_nodes() == 0) return;

  HDS_builder  B(_hds,true);

  B.begin_surface( _base->size_of_nodes(), _base->size_of_elements());
  // insert the vertices
  for (Size i=0; i<_base->size_of_nodes(); ++i) 
  { B.add_vertex( Vertex::Point()); }

  Element_node_enumerator ene( _base, 1);

  for (int i=_base->size_of_elements(); i>0; --i, ene.next()) {
    B.begin_facet();
    for ( int k=0, ne=ene.size_of_edges(); k<ne; ++k) {
      B.add_vertex_to_facet( ene[k]-1);
    }
    B.end_facet();
  }

  B.end_surface();

  // Normalize border vertices such that every border vertex point to its
  // incident border halfedge.
  _hds.normalize_border_vertices();

  // Insert the vertices in edge/face centers for quadratic elements
  if ( _quadratic) {
    Facet *fs = &*_hds.facets_begin();

    Element_node_enumerator ene( _base, 1);
    for (int i=_base->size_of_elements(); i>0; --i, ene.next(), ++fs) {
      int nn = ene.size_of_nodes();
      int ne = ene.size_of_edges();

      Halfedge *h = fs->halfedge();
      for ( int k=ne; k<ne+ne; ++k) {
	Vertex *v = get_vertex_from_id( ene[k]);
	v->set_halfedge( h);
	h = h->next();
      }
      if ( nn == 9) {
	Vertex *v = get_vertex_from_id( ene[8]);
	v->set_halfedge( fs->halfedge());
      }
    }
  }
}
Exemplo n.º 4
0
 typename Facet::Plane_3 operator()( Facet& f) {
     typename Facet::Halfedge_handle h = f.halfedge();
     typedef typename Facet::Plane_3  Plane;
     return Plane( h->vertex()->point(),
                   h->next()->vertex()->point(),
                   h->next()->next()->vertex()->point());
 }
Exemplo n.º 5
0
// Place un point p sur la face fs, et relie p aux sommets de fs.
Halfedge_handle DegradeAnObject::putAPointOnAFacet(Point_3 p, int index) {
	Facet fs;
	getFacetFromPoint(p, fs, index);
	Halfedge_handle h = polys[index].create_center_vertex(fs.halfedge());
	h->vertex()->point() = p;
	return h;
}
Exemplo n.º 6
0
Arquivo: CGsp.cpp Projeto: ASDen/CGsp
    typename Facet::Plane_3 operator()( Facet& f) 
	{
		typename Facet::Halfedge_handle h = f.halfedge();
        // Facet::Plane_3 is the normal vector type. We assume the
        // CGAL Kernel here and use its global functions.
        return CGAL::cross_product( h->next()->vertex()->point() - h->vertex()->point(),
									h->next()->next()->vertex()->point() - h->next()->vertex()->point() );
    }
Exemplo n.º 7
0
// Récupère la liste de tous les points d'une face
std::vector<Point_3> DegradeAnObject::getAllPointsFromFacet(Facet f) {
	std::vector<Point_3> pts;
	Halfedge_handle hh = f.halfedge();
	pts.push_back(hh->vertex()->point());
	hh = hh->next();
	while(hh->vertex()->point() != pts[0]) {
		pts.push_back(hh->vertex()->point());
		hh = hh->next();
	}
	return pts;
}
Exemplo n.º 8
0
void DegradeAnObject::splitEdgesOfFacet(Facet fs, int index) {
	Halfedge_handle hh = fs.halfedge();
	Point_3 p1 = hh->vertex()->point();
	Point_3 p2 = hh->next()->vertex()->point();
	Point_3 p3 = hh->next()->next()->vertex()->point();
	Halfedge_handle hh1 = polys[index].split_edge(hh);
	hh1->vertex()->point() = meanPoints(p1, p3);
	hh = hh->next();
	Halfedge_handle hh2 = polys[index].split_edge(hh);
	hh2->vertex()->point() = meanPoints(p2, p1);
	hh = hh->next();
	Halfedge_handle hh3 = polys[index].split_edge(hh);
	hh3->vertex()->point() = meanPoints(p2, p3);
}
Exemplo n.º 9
0
void DegradeAnObject::refineFacetMesh(Point_3 p, Facet &fs, double epsilon, int index) {
	Facet chkF;
	Halfedge_handle h = splitFacet(fs, index);
	//std::cout << getFacetFromPoint(p, chkF, index) << std::endl;
	if(getFacetFromPoint(p, chkF, index)) {
		if(distanceBetweenPointAndFacet(p, chkF.halfedge()->vertex()->point()) > epsilon) {
			refineFacetMesh(p, chkF, epsilon, index);
		}
		else {
			impactAFace(chkF, index);
		}
	}
	else {
		impactAFace(fs, index);
	}
}
Exemplo n.º 10
0
// Réalise un impact sur la face fs à partir d'une liste de points à déplacer, répartis par couronne (pts[0] = première couronne intérieure, pts[0][0] = premier point de la première couronne)
void DegradeAnObject::impactTheFacetArea(std::vector< std::vector<Point_3> > pts, Facet fs, double ray, int index) {
	double str = 0.02;
	Vector_3 normal = normalizeVector(getNormalOfFacet(fs));
	Kernel::Plane_3 pl(fs.halfedge()->vertex()->point(), normal);
	for(int i = 0 ; i < pts.size() ; i++) {
		for(int j = 0 ; j < pts[i].size() ; j++) {
			bool chk = false;
			Point_iterator pi = polys[index].points_begin();
			while(!chk) {
				++pi;
				if(*pi == pts[i][j]) {
					*pi = Point_3(pi->x() - (impactStrengh(str, i))*normal.x(), pi->y() - (impactStrengh(str, i))*normal.y(), pi->z() - (impactStrengh(str, i))*normal.z());
					chk = true;
				}
			}
		}
	}
}
Exemplo n.º 11
0
// Génère des points autour du point d'impact prévu
std::vector<Point_3> DegradeAnObject::generatePointsOnFacet(Point_3 p, double ray, Facet fs, int nbPts) {
	std::vector<Point_3> pts;
	Vector_3 normal = normalizeVector(getNormalOfFacet(fs));
	Kernel::Plane_3 pl(fs.halfedge()->vertex()->point(), normal);
	Vector_3 orth = (pl.base1()) * ray;
	Vector_3 smallOrth;
	Point_3 chkPt;
	chkPt = p + orth;
	pts.push_back(chkPt);
	Facet test;
	double teta = M_PI/(nbPts/2.0);
	for(int i = 1 ; i < nbPts ; i++) {
		orth = rotationVector(orth, normal, teta);
		chkPt = p + orth;
		pts.push_back(chkPt);
	}
	return pts;
}
Exemplo n.º 12
0
// Casse les arêtes d'une face triangulaire en 2 et les place au centre de son arête. Retourne la liste des pointeurs de ce point
std::vector<Halfedge_handle> DegradeAnObject::splitEdgesOfFacet(Facet fs, int index) {
	Halfedge_handle hh = fs.halfedge();
	std::vector<Halfedge_handle> hhs;
	Point_3 p1 = hh->vertex()->point();
	Point_3 p2 = hh->next()->vertex()->point();
	Point_3 p3 = hh->next()->next()->vertex()->point();
	Halfedge_handle hh1 = polys[index].split_edge(hh);
	hh1->vertex()->point() = meanPoints(p1, p3);
	hhs.push_back(hh1);
	hh = hh->next();
	Halfedge_handle hh2 = polys[index].split_edge(hh);
	hh2->vertex()->point() = meanPoints(p2, p1);
	hhs.push_back(hh2);
	hh = hh->next();
	Halfedge_handle hh3 = polys[index].split_edge(hh);
	hh3->vertex()->point() = meanPoints(p2, p3);
	hhs.push_back(hh3);
	return hhs;
}
Exemplo n.º 13
0
// Retourne le vecteur normal d'une face
Vector_3 DegradeAnObject::getNormalOfFacet(Facet fs) {
	Vector_3 normal = CGAL::cross_product(fs.halfedge()->next()->vertex()->point() - fs.halfedge()->vertex()->point(), fs.halfedge()->next()->next()->vertex()->point() - fs.halfedge()->next()->vertex()->point());
	return normal;
}