insert edges in faces- CGAL error: assertion violation - c++

I'm creating an application using qt creator which read .off files as CGAL::Linear_cell_complex_for_combinatorial_map and preview it I want to make operations on the read mesh such as removing edge and restore it .
it shows the following error :
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: is_insertable_cell_1_in_cell_2(adart1, adart2)
I searched about it but I cannot get an useful solution
QWidget* viewer ;
std::string filename;
Dart_handle dh3;
LCC_3 lcc;
QMainWindow qWin;
CGAL::DefaultColorFunctorLCC fcolor;
void MainWindow ::insertCell()
{
dh3=lcc.insert_cell_1_in_cell_2(lcc.darts().begin(), lcc.darts().end());
CGAL_assertion( lcc.is_valid() );
lcc.display_characteristics(std::cout) << ", valid=" <<
lcc.is_valid() << std::endl;
setCentralWidget( new CGAL::SimpleLCCViewerQt<LCC_3, CGAL::DefaultColorFunctorLCC>(&qWin ,
lcc,
"Basic LCC Viewer",
false,
fcolor ) );
show();
}
void MainWindow ::removeCell()
{
CGAL_assertion( (lcc.is_removable<2>(dh3)) );
lcc.remove_cell<1>(dh3);
CGAL_assertion( lcc.is_valid() );
lcc.display_characteristics(std::cout) << ", valid="
<< lcc.is_valid() << std::endl;
}
any help? or usefull links to simplify mesh or removing vertices , edges or faces ?
I appreciate any help

To insert an edge in a face, cf the doc here. For a face in a volume, the doc is there. You can also have a look at the example here.
The important thing to understand is when you add an edge into a face, you need to say where to insert the edge. This is the reason why you give two precise darts. This is similar when you want to insert a face into a volume: you need to give a sequence of darts which is a cycle of edges in the volume.

Related

Magick++ gif annotation artefacts

I want to make an annotation in a gif image using ImageMagick and specifically Magick++, the code is quite simple, but the output image has artifacts in the text, if the gif does not move, then the artifacts do not appear, here:
here is the code itself, very simple:
int main()
{
InitializeMagick(nullptr);
list<Image> *imageList = new list<Image>();
try {
readImages(imageList, "source.gif" );
}
catch( exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
for(Image &i : *imageList) {
i.fontPointsize(36);
i.font("helvetica-bold");
i.fillColor(Color("white"));
i.fontStyle(MagickCore::ObliqueStyle);
i.annotate("why are you lagging", SouthGravity);
}
writeImages(imageList->begin(), imageList->end(), "/home/deymos/GifnText/n.gif");
return 0;
I tried to save the list of images as png and this is what I saw when the movement on the gif started:
is it possible to fix it, or is it a bug?
If this cannot be fixed, maybe there are similar tools with which I can implement text on gifs? or at least a library that can disassemble gifs into images and fold, I can do the rest with qt, tnx.

How to delete faces from mesh using openmesh?

Pretty much the title I am trying to delete a few faces of a mesh using open mesh, like this:
MyMesh mesh;
char fname[1024];
sprintf(fname, "box_%i.obj", 0);
if (!OpenMesh::IO::read_mesh(mesh, std::string(fname)))
{
std::cerr << "read error\n";
exit(1);
}
MyMesh::FaceIter v_it, v_end(mesh.faces_end());
uint count = 0;
for (v_it=mesh.faces_begin(); v_it!=v_end; ++v_it)
{
mesh.delete_face(*v_it, true);
}
This is segfaulting on the first call to delete_face.
However, writing this mesh (without trying to delete faces):
if (!OpenMesh::IO::write_mesh(mesh, std::string("open_mesh.obj")))
{
std::cerr << "write error\n";
exit(1);
}
Works perfectly fine and blender can open the obj. So the issue very much seems to be with how I am trying to delete the faces.
The docs don;t seem to provide any explanation as to why this is not valid:
https://www.graphics.rwth-aachen.de/media/openmesh_static/Documentations/OpenMesh-Doc-Latest/a02618.html#ae20c4e746b52c34ace6a7b805fbd61ac
I think iterator being invalid after removing an element in it.
for (v_it=mesh.faces_begin(); v_it!=v_end; ++v_it)
{
mesh.delete_face(*v_it, true);
v_it = mesh.faces_begin(); //<- add this to test
}

Issues trying to make a filter using Qt

I'm trying to make my software filter a list of elements.
I think I need to put my data in a TableWidget because I have to display other information.
I also put 3 Line Edit to search respectively in each category (called leName, leSource, leDestination)
so I tried to implement my filter for the name property, for now I have :
void MyClass::on_leName_textEdited(const QString &arg1)
{
for (int i=0;ui->tableWidget->rowCount()-1;i++)
{
qDebug()<<"before if";
if(ui->tableWidget->item(0,1)->text().contains(arg1) //tried with &arg1, I have the same issue, for now
{
qDebug()<<"If validated";
ui->tableWidget->showRow(i);
}else{
qDebug()<<"If not validated"
ui->tableWidget->hideRow(i)
}
}
}
When I hit a key, my soft crashes
I get "Before if", "If (not) validated", "Before if" from qDebug
I launched with debbugger and got Segmentation fault as error
not sure what I could add as detail about my error
Maybe I did nothing in the good way, I'm no expert in Qt nor c++
If you have any idea of what I should do to correct this, I would appreciate it =)
The fact that a cell exists does not imply that it has an associated QTableWidgetItem, so you must verify that it is not null.
QTableWidgetItem * item = ui->tableWidget->item(0, 1);
if(item && item->text().contains(arg1))
{
qDebug() << "If validated";
ui->tableWidget->showRow(i);
}else{
qDebug() << "If not validated"
ui->tableWidget->hideRow(i)
}

Text over picture

Is it possible to create text displayed on a picture with nana?
I tried this
int main() {
using namespace nana;
form fm;
place plc(fm);
picture pic(fm);
label lbl(fm, "LBL", true);
pic.load(paint::image("xxx.png"));
pic.caption("PIC");
pic.align::center, align_v::center);
lbl.transparent(true);
lbl.text_align(align::center, align_v::center);
plc.div("<<here>>");
plc["here"] << pic;
plc["here"] << lbl; // (1)
plc.collocate();
lbl.move(pic.pos());
fm.show();
exec();
}
But its shifting both to the left as nana creates a grid for 2 elements in the layout. Without adding it, so deleting (1), the label will not be shown in the layout at all.
I couldnt find any information on it online. nana::image::caption(std::string) method seems to be ignored
Is there a way to get two elements on top of each other, in a place of one element? My goal is make a picture of a waterdrop and then writing the humidity-% in the middle of it.
Thank you
Display your picture, then use nana::paint::graphics::string to write your text on top of the picture.
This
is produced by
#include <iostream>
#include <nana/gui.hpp>
#include <nana/gui/widgets/picture.hpp>
#include <nana/gui/widgets/label.hpp>
int main()
{
using namespace nana;
paint::image I("xxx.bmp");
if (I.empty())
{
msgbox err("Error");
err << "Cannot read image";
err.show();
exit(1);
}
form fm({50,50,400,700});
drawing dw(fm);
dw.draw([&I](paint::graphics& g)
{
I.paste(g, {0,0} );
g.string({200,400}, "THIS IS A TEST", colors::black);
});
fm.show();
exec();
}

"Unable to read font " ImageMagick++

i try this little bit a of code :
try {
InitializeMagick(*argv);
//create a base image
Image image("400x100",font_color);
//construct a drawing list
std::list<Magick::Drawable> drawList;
//add tracing elements
drawList.push_back(DrawableRectangle(0,0,400,100)); // Draw a rectangle ( the sign)
drawList.push_back(DrawableStrokeColor("black")); // Outline Color
drawList.push_back(DrawableFillColor(font_color)); // Fill color
drawList.push_back(DrawableStrokeWidth(5));
drawList.push_back(DrawablePointSize(50));
drawList.push_back(DrawableFont("#Arial"));
drawList.push_back(DrawableStrokeColor(police_color));
drawList.push_back(DrawableText(10,70,ville));
drawList.push_back(DrawableText(300,70,distance));
image.draw(drawList);
image.write(filedest);
}
catch(exception & error_)
{
cout<<"Caught exception : " << error_.what() << endl;
}
but i get this error when i start the program :
proto.exe:unable to read font `#Arial' # error/annotate.c/RenderFreetype/1126
Just drop the # sign in the font name. It's not needed for the Magick::DrawableFont method.
drawList.push_back(DrawableFont("Arial"));
You can verify the fonts available by running the identify utility.
identify -list font | more