Help needed with C and C++
-
- Addict
- Posts: 1265
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Help needed with C and C++
I know this is an unusual request, but the program is freeware. It is Triangle by Jonathan Shewchuk. Unfortunately there doesn't seem to be a compiled exe of it anywhere online. The source code is three .c files and an .h file. Obviously I would do this myself but I really don't know where to begin with C and I have no tools with which to compile these programs. If somebody could do this for me, I would be very grateful indeed. Just to show that I am not totally selfish, this is all part of an effort to write Pb code that will convert 2D SVG graphics into 3D models, and the code will be shared on the forum. There is no code for triangulating (also called tessellating) polygons on the forum so I think many PB users could benefit from Triangle.
Thank you,
Seymour.
Thank you,
Seymour.
Last edited by Seymour Clufley on Sat Sep 28, 2013 7:27 pm, edited 1 time in total.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: Could somebody compile this C program for me?
Seymour,
I am sorry, but I do not have time to take care of it for you. However, I can point you to a few directions so you can. It has been a while, but I have used the Code::Blocks IDE, which has a download bundled with MINGW C compiler. (I believe that is a GCC.) I suggest this one because in one (large) download you will have an IDE and compiler installed and usable. This is most likely a better bet.
http://www.codeblocks.org/
Another which I have read about lately, but not used, is PellesC. Pelles wrote his own IDE, and improved upon the o/s LCC compiler. This one is probably simpler, and more like PB due to their tight integration.
http://www.smorgasbordet.com/pellesc/
I am sorry, but I do not have time to take care of it for you. However, I can point you to a few directions so you can. It has been a while, but I have used the Code::Blocks IDE, which has a download bundled with MINGW C compiler. (I believe that is a GCC.) I suggest this one because in one (large) download you will have an IDE and compiler installed and usable. This is most likely a better bet.
http://www.codeblocks.org/
Another which I have read about lately, but not used, is PellesC. Pelles wrote his own IDE, and improved upon the o/s LCC compiler. This one is probably simpler, and more like PB due to their tight integration.
http://www.smorgasbordet.com/pellesc/
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Could somebody compile this C program for me?
.....The c files are pretty old -the code needs updating to compile an exe, requires a fair bit of time to do that. Also, there are some apparently non-standard libs included (non standard in that Triangle was developed on Unix and we want to compile on Windows)
In Triangle.c: sys/time.h Probably not a problem to replace the code that depends on this file.
In ShowMe.c (Seperate project): X11/Xlib.h, X11/Xutil.h, X11/Xatom.h
However Seymour, triangulation of this kind is intended for really complex Objects, mechanical engineering components etc. If you use it for your shapes you will have thousands of unnecessary triangle faces.........
In Triangle.c: sys/time.h Probably not a problem to replace the code that depends on this file.
In ShowMe.c (Seperate project): X11/Xlib.h, X11/Xutil.h, X11/Xatom.h
However Seymour, triangulation of this kind is intended for really complex Objects, mechanical engineering components etc. If you use it for your shapes you will have thousands of unnecessary triangle faces.........
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Could somebody compile this C program for me?
I got triangle.c to compile no problem, I'll dig up the xlib files and compile the showme.c ... give me a bit.
---
They both compiled w/o issue (no errors or warnings).
Binary (exe) and resultant demo files can be downloaded here
however, when I ran the example, showme was unable to run.
---
They both compiled w/o issue (no errors or warnings).
Binary (exe) and resultant demo files can be downloaded here
however, when I ran the example, showme was unable to run.
and it exited/returned 1Opening &.node.
Error: Cannot access file &.node.
Error: Cannot open display.
Last edited by jassing on Sat Sep 28, 2013 8:39 pm, edited 1 time in total.
-
- Addict
- Posts: 1265
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: Help needed with C and C++
That would be very helpful, Jassing. I did find the QHull utility and got it to work with PB, only to discover that it can't handle concave polygons, only convex ones. That was when I posted this thread about Triangle, which seems to be able to handle anything.
Using Dev C++ I've managed to compile PolyPartition. But now I need to work out how to use it! There are no examples supplied. The guy just says "For input parameters and return values see method declarations in polypartition.h". Here is the method I'm interested in:
ED...
*func comes out as 0 here.
I've also tried CountLibraryFunctions() and ExamineLibraryFunctions() - both come out as 0.
I'm aware of that danger, IV. This is why I've been looking around for other solutions. I found a library, PolyPartition, and from the images it seems to triangulate polygons very efficiently. And my polygons are simpler than that one.IdeasVacuum wrote:However Seymour, triangulation of this kind is intended for really complex Objects, mechanical engineering components etc. If you use it for your shapes you will have thousands of unnecessary triangle faces...
Using Dev C++ I've managed to compile PolyPartition. But now I need to work out how to use it! There are no examples supplied. The guy just says "For input parameters and return values see method declarations in polypartition.h". Here is the method I'm interested in:
The program has been compiled as a console DLL. It's been many years since I used a DLL! Can anyone tell me how one would call that function from a PB program?int Triangulate_EC(TPPLPoly *poly, list<TPPLPoly> *triangles);
ED...
Code: Select all
lib = OpenLibrary(#PB_Any,"C:\test\PolyPartition.dll")
If lib
*func = GetFunction(lib,"Triangulate_EC")
Debug "FUNC: "+Str(*func)
CloseLibrary(lib)
Else
Debug "Could not open DLL!"
EndIf
I've also tried CountLibraryFunctions() and ExamineLibraryFunctions() - both come out as 0.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: Help needed with C and C++
See my previous post for a download link. Unfortunately, showme didn't work as expected... But I'm out of my depths when it comes to x11 stuff....Seymour Clufley wrote:That would be very helpful, Jassing.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Help needed with C and C++
@jassing, did you replace the insecure C functions with secure ones?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Help needed with C and C++
I changed only the location of the xlib files; otherwise, I changed nothing...IdeasVacuum wrote:@jassing, did you replace the insecure C functions with secure ones?
Re: Help needed with C and C++
Both compiled with a full installation of Cygwin (www.cygwin.com).
1. edit makefile - removing "-DLINUX"
2. type "make"
1. edit makefile - removing "-DLINUX"
2. type "make"
Re: Help needed with C and C++
did showme work?kns wrote:Both compiled with a full installation of Cygwin (http://www.cygwin.com).
1. edit makefile - removing "-DLINUX"
2. type "make"
Re: Help needed with C and C++
I haven't looked at what this code is meant to do...however, typing './showme' generates a short help screen of options/arguments. It appears to work, at least to that point.jassing wrote:did showme work?kns wrote:Both compiled with a full installation of Cygwin (http://www.cygwin.com).
1. edit makefile - removing "-DLINUX"
2. type "make"
Edit: Yes, once the Cygwin XServer is started showme works.
Edit2: The Cygwin XServer might be a bit flakey when starting and launching an XTerm. There is also XMing and http://mobaxterm.mobatek.net/ among others.
-- starting xterm: https://www.dropbox.com/s/59jvkep0gxu8q9i/xterm.png
-- showme: https://www.dropbox.com/s/t34n72jnwtxc8 ... 113309.png
Last edited by kns on Sun Sep 29, 2013 4:33 pm, edited 2 times in total.
Re: Help needed with C and C++
well; if you read the readme -- it shows a simple example, in the archive was a test file -- showme would run for me too; it just wouldn't process the file.
Re: Help needed with C and C++
See above. You need an XServer running.jassing wrote:well; if you read the readme -- it shows a simple example, in the archive was a test file -- showme would run for me too; it just wouldn't process the file.
-
- Addict
- Posts: 1265
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: Help needed with C and C++
I want to thank everyone who gave advice in this thread or compiled these two programs. When I asked for this help yesterday morning I really did think it was necessary. However, I have since had a go at the triangulation problem myself and I seem to have cracked it.
I do not ask people to compile C++ programs for me very often - in fact it's the first time I've ever done it - so please don't think it was too selfish of me. It just seemed, at the time, the only way to obtain a solution.
Thanks again.
I do not ask people to compile C++ programs for me very often - in fact it's the first time I've ever done it - so please don't think it was too selfish of me. It just seemed, at the time, the only way to obtain a solution.
Thanks again.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: Help needed with C and C++
glad you got it sorted out.
as it happened, I was working on C code that day, (for helping a friend in a remote research facility, which I think is pretty cool in and of itself) and there was talk of porting to unix; so it was good practice.
if you need help again, feel free to PM me
as it happened, I was working on C code that day, (for helping a friend in a remote research facility, which I think is pretty cool in and of itself) and there was talk of porting to unix; so it was good practice.
if you need help again, feel free to PM me