Get halfedge from edge in cgal - cgal

what I need to do is given a edge_iterator and get a halfedge_handle,I checked the cgal document and feel confused
here is my code
for(Edge_iterator ei = mesh.edges_begin();
ei != mesh.edges_end(); ei++){
// get the halfedge handle
}
I know this looks like a silly question, just can't find the answer, thanks

An edge is simply one of the two opposite halfedges.
You can simply write
Halfedge_handle h = ei;

Related

Histogram with ntuple using CERN ROOT

Can't obtain/fill histogram starting from ntuple using ROOT.
I have been looking for previous answers and they all use ttree, including root documentation. I dont have one. Not new to root, but i struggle A LOT using it. None of the methods found work with my code (or i dont know how to implement them).
This is more or less what i have found everywhere:
https://root.cern.ch/root/roottalk/roottalk03/2620.html
but no, i am doing TH1F and i have no ttree (see code below)
{
gROOT->Reset();
#include "Riostream.h"
#include <iostream>
#include <fstream>
in.open( "somefile.dat");
TNtuple *ntuple = new TNtuple("ntuple","some data from ascii file","index1:index2:index3");
//declare variables, create histograms
Double_t x,y,Price[215000],Diff[215000],Ret[215000],trend, Data[215000];
TFile *f = new TFile("TrendsCountBove.root","RECREATE");
TH1F *h1 = new TH1F("h1","Retornos",100,-0.3,0.3);
TH1F *histo = new TH1F ("hist_from_ntuple", "some title", nbins, min,max);
//do some stuff (didn't paste all calculations i do, but that works fine)
for (Int_t i = 0; i+1 < nlines-1; i++) {
Diff[i] = Price[i+1]-Price[i];
Ret[i] = TMath::Log(Price[i+1])-TMath::Log(Price[i]);
h1->Fill(Ret[i]);
ntuple->Fill(i*1.0,Ret[i],Price[i+1]);
}
So, it all works fine, no problem at all. But then again if please somebody could explain me as detailed as possible how can i fill histo with, say, index1, or 2 or 3. I suck at c++ and i dont really like it nor understand it.
I expect a beautiful histogram where i can set all things like title, max and minimum, stat box, etc. By default root does it via ntuple but it's not what i need.
Thank so much in advance.
Thank you so much guys, first answer worked just right.
Now, i'd love to use python instead of ROOT. Problem is, my thesis directors (both physicists, both from particles) never wanted to do so. As a result, suffering for about six months with c++ and ROOT. Such a drag.
Thanks again!

CGAL surface mesh - removing face

Does the remove_face method change the mesh indices?
I get a segmentation fault with this code:
auto face_iterator = m.faces_around_target(m.halfedge(v3));
for (auto i=face_iterator.begin(); i!=face_iterator.end(); i++) {
m.remove_face(*i);
}
According to my understanding of the documentation, as long as I don't call collect_garbage the faces are only marked as removed., therefore no changes to indices. What is happening?
Does remove_face, also remove the face halfedges\ makes them point to null_face? It does not seem to do so, and I don't understand why not..
Thank you.
The face is indeed simply marked as removed but its iterator is invalidated by the removal (remember that iterator goes only over non-removed elements).
As stated in the doc: removes face f from the halfedge data structure without adjusting anything.
You need to use a higher level function such as CGAL::Euler::remove_face().

CGAL: Access to Results of find_conflicts()

So I am very confused about the find_conflicts function in CGAL. I thought I knew std::pair, and I thought I knew what was going on in find_conflicts(), but for the life of me, I am not sure how to access the results. I thought that the iterator that is passed to find_conflicts would be enough to then access the values directly. (i.e., I want to get at those facets that I put in the "vector facets,") and it appears as if I'm doing that because I can successfully
typedef std::pair<std::vector<Facet>, std::vector<Cell> > FacetAndCell;
* * *
Cell_handle cell = T.locate(curr_point);
std::vector<Facet> facets;
T.find_conflicts(curr_point, cell, std::back_inserter(facets), CGAL::Emptyset_iterator());
CGAL::First_of_pair_property_map<FacetAndCell> my_p_map();
Delaunay::Finite_facets_iterator ff_iter;
std::vector<Facet>::iterator facet_iter;
// Here, what I'm trying to achieve is figuring out which of the facets
// in conflict are finite. I had wanted to use some kind of test like
// "is_infinite()" on the facet at hand, but this isn't available for
// a facet out of context of the triangulation it's part of.
for(facet_iter = facets.begin(); facet_iter != facets.end(); facet_iter++){
for(ff_iter = T.finite_facets_begin(); ff_iter != T.finite_facets_end(); ff_iter++){
// Since I get an error that facet_iter is actually of type pair, I thought this would work, but it doesn't.
// ERROR!
cout << facet_iter->first << endl;
// This works, which is what led me to believe I was comparing one facet to another facet.
/*
if(*facet_iter == *ff_iter){
cout << "Finite facet!" << endl;
break;
}*/
}
}
In summary:
1) Overall, I want to know which facets from the result of find_conflicts() were finite. If there is an easier way to do this, feel free to let me know.
2) Otherwise, the more specific problem here is that I need to get at that vector of facets that results from find_conflicts() and then get at the vertices of each facet. Am I supposed to be working with the returned "pair" of cells and facets or can I access the vector directly, like I'm trying to do?
Help, please, thanks.
For finiteness testing, use is_infinite(). See http://doc.cgal.org/latest/Triangulation_3/classCGAL_1_1Triangulation__3.html#af024721d3ae4b9327ffe442fb828935c
Otherwise, maybe you are confused because the Facet type is a typedef to a pair (unfortunately).
PS: alternatively, you can use Marc Glisse's suggestion in your other question (using locate(midpoint(p, sphere center))). It might be easier. CGAL Using Locate() to Find Cell on Triangulation Surface

Java 3D: Get intersection of two Shape3D's?

Is it possible to get the intersection co-ords of two shapes3d's?
(One is a Line and the other is a QuadArray)
Just wondering if there is a simple way before I try a hack and slash method?
-I'm pretty new to Java 3D so I may have missed a function which does exactly what I need.
The Easy way is to use Bounds and intersect method :
Bounds quadArrayBounds = quadArrayShape.getBounds();
if (quadArrayBounds.intersect(new Point3d(startLine.x, startLine.y, startLine.z),
new Vector3d(endLine.x, endLine.y, endLine.z))){
// Action to do if Intesect is true
}

How to calculate current position on a great circle path

Given a starting point (origLat, origLon), ending point (destLat, destlon), and a % of trip completed. How do I calculate the current position (curLat, curLon)?
Aviation Formulary is a great resource which covers this question and more.
MTL provides some good content on great circle computations and some working applets you can use to verify your implementation.
In this case, it should be really simple:
curLat = origLat + percentageOfTripCompleted*(destLat-origLat);
curLon = origLon + percentageOfTripCompleted*(destLon-origLon);
*The fact that the earth is a sphere really has no bearing on this problem.