Subject: CGAL users discussion list
List archive
- From: Ben McWhorter <>
- To:
- Subject: Re: [cgal-discuss] Problems with Nef_Polyhedron
- Date: Wed, 15 Jun 2011 14:24:22 -0400
Hi Sebastian,
The reason that I test if they are disjoint before joining is because I need each disjoint nef polyhedron to be output separately.
Also, the problem that I was having is that when I would join them together without the check, I would get resulting nef polyhedron that were either not simple or not valid.
Doing the join the way I do, gives me outputs that are all simple and valid. I don't believe that you will have a problem with those 3 examples I sent in particular, but simply joining all of my input together in the manner you did gives me a result that is either not simple or not valid.
Does that make more sense?
If you want me to show you an example of the join producing this invalid output, I can find some example input that displays the problem.
Thanks,
Ben
On Jun 15, 2011, at 12:51 PM, Sebastien Loriot (GeometryFactory) wrote:
Sorry but still not sure to get your problem.
I try to make the union of output3.off, output4.off and output5.off
in one run, with a (what I call minimal) example joint. I don't have
time to understand all your code but why are you testing if nef are
disjoint before making the union?
Joining disjoint nef polyhedra is handled.
Anyway, I may be wrong but to me it seems that the need of the two runs
come from the way you handle the union.
Sebastien.
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/IO/Nef_polyhedron_iostream_3.h>
#include <CGAL/OFF_to_nef_3.h>
#include <iostream>
#include <fstream>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
int main(int, char *argv[]) {
std::ifstream off1(argv[1]);
std::ifstream off2(argv[2]);
std::ifstream off3(argv[3]);
Nef_polyhedron n1,n2,n3;
CGAL::OFF_to_nef_3(off1,n1);
CGAL::OFF_to_nef_3(off2,n2);
CGAL::OFF_to_nef_3(off3,n3);
n1 += n2;
n1+=n3;
Polyhedron p;
n1.convert_to_polyhedron(p);
std::cout << p << std::endl;
}
Benjamin McWhorter wrote:
Hi Sebastian, Thanks again for your help. The following .cpp file is what I have been using. I am reattaching the files I sent in the last email with it. The print_polyhedron_wavefront isn't really too important, it takes only a polyhedron input (so I do use convert_to_polyhedron), it is just convenient to get the output in a .obj file so I can look at it in meshlab. This program takes a directory name as input, where the .obj files lie. It creates .OFF files for each .obj and then tries to join them. The first time you run with the attached 3 .obj files, you will get 2 .obj files as output. If you then run it again with those two output .obj files, you will get one output.
What I was hoping is that I would get one output from the first time I ran the program.
Thanks again,
Ben
------------------------------------------------------------------------
On Jun 15, 2011, at 11:38 AM, Sebastien Loriot (GeometryFactory) wrote:Not sure to understand what you want.
1)You want to make 1+2+3 but you can't because it seems that the union
is not possible when object are disjoint. if so could you provide 1,2
and 3 as off (a private message only for the files is better or a URL).
2)I do not know the function print_polyhedron_wavefront (which is not
documented), I am using the member function convert_to_polyhedron.
However it may happen that some degenerate faces appear when converting
exact coordinates to double. Do you have the same result when using
convert_to_polyhedron?
Providing a minimal example is very appreciated, I then just need to
compile it without having to create it from scratch (and this ensures
we have the same setting).
Sebastien.
Benjamin McWhorter wrote:
Hi Sebastian,
Sorry if I wasn't clear on my problem. I have attached my original input .obj files and the resulting converted .off files.
The problem that I am having is this, while I get an intersection and a resulting join that is valid between 2 of the 3, CGAL does not find a valid and simple join between the result of that join and the other nef_polyhedron (hopefully thats clear). My process for performing the join is like this:
convert .obj to .off
create nef_polyhedron from .off using the off_to_nef3 constructor.
test if there is an intersection between the two nef_polyhedron
if there is test if the result of a join between the two would give a simple and valid result
if so, join them.
I then convert back to polyhedron and write the output to a file using print_polyhedron_wavefront
The problem is that running the program on the attached 3 inputs gives 2 resulting nef_polyhedron. If I run the program again, (using the output from the first run as input), then it will join the two polyhedron (after discarding the facets you mentioned when constructing the Nef_polyhedron).
So I basically have two questions -- why is it that these nef_polyhedron do not get joined in the first place?
Second -- why is CGAL's output (from print_polyhedron_wavefront) is giving me Polyhedron with degeneracies, when I do not get that problem from the attached input -- only CGAL produced input.
I hope that all makes sense and as always I very much appreciate your help.
Thanks,
Ben
------------------------------------------------------------------------
On Jun 15, 2011, at 3:36 AM, Sebastien Loriot (GeometryFactory) wrote:If you are using the construction from polyhedron,
nef assumes that the input is a valid polyhedron.
Your input output4.OFF contains facets made only of collinear
points.
The following code detect these facets:
for (Polyhedron::Facet_iterator f=poly.facets_begin();
f!=poly.facets_end();++f)
{
Kernel::Point_3 pt1,pt2,pt3;
pt1=f->halfedge()->vertex()->point();
pt2=f->halfedge()->next()->vertex()->point();
Polyhedron::Halfedge_handle h=f->halfedge()->next();
do{
pt3=f->halfedge()->next()->next()->vertex()->point();
if (! CGAL::collinear(pt1,pt2,pt3) ) break;
h=h->next();
}
while(h!=f->halfedge());
if( h==f->halfedge() )
std::cerr<<"Error degenerate facet" << std::endl;
}
In order to remove this kind of degeneracies, you can use the
function CGAL::OFF_to_nef_3 documented here:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Nef_3_ref/Function_OFF_to_nef_3.html
Using this function I was able to make the union of your
inputs with CGAL-3.8.
Sebastien.
Benjamin McWhorter wrote:
Hello All,--
I have been having some trouble correctly joining Nef_Polyhedron. I have attached some .off files that should recreate the error. I have been trying to join a large number of Polyhedron using CGAL and ran into many problems along the way. I found that I cannot simply join the simple and valid nef_polyhedron and expect a simple and valid result. The only way I was able to accurately join them was by testing if the result of the join was simple and valid after checking if there was an intersection and if it passed all three tests, then perform the join.
It seems that the order in which I joined them had a lot to do with it working out.
Anyhow, on to my actual issue. I ran the join and expected the following two polyhedron to be joined, but they were not. After the join I convert back to Polyhedron and then use the print_polyhedron_wavefront function to write the output in an .obj file.
These .OFF files that I attached are simply print_polyhedron_wavefront .objs that I have converted to .OFF. These two were not joined during execution, however, when I ran the program again with these two as input, I get the following (sorry if I put too much). I am wondering why CGAL is discarding facets that were created by the print_polyhedron_wavefront function and 2, why these two were not joined in the first place. Any help is much appreciated.
Thanks,
Ben
------------------------------------------------------------------------
output4.OFF
Conversion from vertex cycle to Nef_polyhedron_3 was not successful. Error history: -> function parameter 'normal' is NULL_VECTOR (this can be a symptom of an error). Now, direction of projection is 'x'. -> Same vertex appears multiple in cycle. Now, direction of projection is 'y'. -> Same vertex appears multiple in cycle. Now, direction of projection is 'z'. -> Same vertex appears multiple in cycle. Finally, empty Nef_polyhedron_3 was constructed.
Hence, discard input facet 14 (enumerated beginning with 1). Check semantics!
Conversion from vertex cycle to Nef_polyhedron_3 was not successful. Error history: -> function parameter 'normal' is NULL_VECTOR (this can be a symptom of an error). Now, direction of projection is 'x'. -> Same vertex appears multiple in cycle. Now, direction of projection is 'y'. -> Same vertex appears multiple in cycle. Now, direction of projection is 'z'. -> Same vertex appears multiple in cycle. Finally, empty Nef_polyhedron_3 was constructed.
Hence, discard input facet 21 (enumerated beginning with 1). Check semantics!
Conversion from vertex cycle to Nef_polyhedron_3 was not successful. Error history: -> function parameter 'normal' is NULL_VECTOR (this can be a symptom of an error). Now, direction of projection is 'x'. Now, direction of projection is 'y'. Now, direction of projection is 'z'. -> Different vertices are projected to same location! Finally, empty Nef_polyhedron_3 was constructed.
Hence, discard input facet 29 (enumerated beginning with 1). Check semantics!
Conversion from vertex cycle to Nef_polyhedron_3 was not successful. Error history: -> function parameter 'normal' is NULL_VECTOR (this can be a symptom of an error). Now, direction of projection is 'x'. -> Same vertex appears multiple in cycle. Now, direction of projection is 'y'. -> Same vertex appears multiple in cycle. Now, direction of projection is 'z'. -> Different vertices are projected to same location! Finally, empty Nef_polyhedron_3 was constructed.
Hence, discard input facet 30 (enumerated beginning with 1). Check semantics!
Conversion from vertex cycle to Nef_polyhedron_3 was not successful. Error history: -> function parameter 'normal' is NULL_VECTOR (this can be a symptom of an error). Now, direction of projection is 'x'. -> Same vertex appears multiple in cycle. Now, direction of projection is 'y'. -> Same vertex appears multiple in cycle. Now, direction of projection is 'z'. -> Different vertices are projected to same location! Finally, empty Nef_polyhedron_3 was constructed.
Hence, discard input facet 51 (enumerated beginning with 1). Check semantics!
output4.OFF is simple
output4.OFF is valid
output3.OFF
output3.OFF is simple
output3.OFF is valid
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
- [cgal-discuss] Problems with Nef_Polyhedron, Benjamin McWhorter, 06/15/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Sebastien Loriot (GeometryFactory), 06/15/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Benjamin McWhorter, 06/15/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Sebastien Loriot (GeometryFactory), 06/15/2011
- Message not available
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Sebastien Loriot (GeometryFactory), 06/15/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Ben McWhorter, 06/15/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Sebastien Loriot (GeometryFactory), 06/16/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Benjamin McWhorter, 06/21/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Ben McWhorter, 06/15/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Sebastien Loriot (GeometryFactory), 06/15/2011
- Message not available
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Sebastien Loriot (GeometryFactory), 06/15/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Benjamin McWhorter, 06/15/2011
- Re: [cgal-discuss] Problems with Nef_Polyhedron, Sebastien Loriot (GeometryFactory), 06/15/2011
Archive powered by MHonArc 2.6.16.