Testing Ruby VALUES in C-extension.
-
@jolran said:
I'm using a Hash with uniq points. And then building different geometries from those points for rendering Open_Gl Triangles and edges.
Normally the ordering of points for face-triangles VS face-edges are different.
So one ends up with 2 arrays of points. 1 for GL_Triangles , 2 for GL_edges.NOW, Instead of having 3 Containers filled with points. You have only 1 HASH. And 2 Arrays of integers that act as lookups-key to the Hash.
I'd try to wrap that whole calculation in a C extension. C++ extension that is.
@jolran said:
Using Polygonmesh for this would be better, but one cannot update or purge a polygonmesh.
I'm dealing with this right now for my subdivision extension. Working on live update of the mesh when you adjust the creasing. (And any other part of the mesh.) Lots of things to keep in sync - lots of ways to get it wrong.
-
This is all very interesting!
-
Btw guys, have you heard of DevCamp we're doing in Greece at the end of September?
http://forums.sketchup.com/t/sketchup-developer-event-devcamp-2014/255If you are able to come we can probably do a C extension session if there is enough interest.
-
@tt_su said:
If you are able to come we can probably do a C extension session if there is enough interest.
That would be great!
I'm looking forward to meet you guys there
-
Wooah! You seam to have gotten far into this C++ business. Well done!
@unknownuser said:
I'd try to wrap that whole calculation in a C extension. C++ extension that is.
I should probably have mentioned that these containers are long lived. The may exist during the whole program.
I do have some more special methods for dealing with other objects(node-editor project) but for this purpouse it would be most intersting to se an example on how you do things in C++ in an isolated case.
In fact, It may be interesting for the whole communitive. (as long as we can use/abuse/expand on it in our projects, that is )@unknownuser said:
Indeed. I have VS2013. You can load the project just fine, but if you want to use it as-as you must decline to upgrade it.
If you do choose to upgrade you must modify the Ruby headers as they are not configured to VS2013. That's what I do for my projects now because I like C++11 so much with it's lambdas, smart pointers, ranged for loops and other goodnesses.Ah ok. Well My brother gave me a seat of VS 2010 ULTIMATE. Can't really afford upgrading that..$$$$
@unknownuser said:
It is in fact set up to SU2014. When you click run it should launch SketchUp 2014 and a supplementary RB script should load the c extension for you.
Edit: That doesent happend for me. I get linking errors. I'll look into it more. I wasent aware I could debugg it like that. Sounds a bit more flexible
Ehh. I don't have 2014 either.. Not Pro anyway. Make will work ?edit: I linked to Sketchup8 which it now seams to find, but I'll keep getting errors.
'SketchUp.exe': Loaded 'C:\Windows\SysWOW64\mscms.dll', Cannot find or open the PDB file
I think I may have linked the RubyStartup "$(SolutionDir)Ruby$(Configuration).rb" file wrong..For the rest of the information.
Very informative post this is turning out to be! -
@unknownuser said:
Btw guys, have you heard of DevCamp we're doing in Greece at the end of September?
Ahhh, Greece. Man, that would have been nice...
-
@jolran said:
Ah ok. Well My brother gave me a seat of VS 2010 ULTIMATE. Can't really afford upgrading that..$$$$
Visual Studio Express editions are free. Are you using any features in Ultimate which Express doesn't have? (VS2013 is really nice - I like it so much more than VS2010.)
And using the Test Explorer with the Google Runner extensions is also very nice for setting up unit tests.
@jolran said:
Edit: That doesent happend for me. I get linking errors. I'll look into it more. I wasent aware I could debugg it like that. Sounds a bit more flexible
Ehh. I don't have 2014 either.. Not Pro anyway. Make will work ?Make will work. Any version of SketchUp that support the RubyStartup argument. (I don't recall when that was added.)
@jolran said:
edit: I linked to Sketchup8 which it now seams to find, but I'll keep getting errors.
'SketchUp.exe': Loaded 'C:\Windows\SysWOW64\mscms.dll', Cannot find or open the PDB file
I think I may have linked the RubyStartup "$(SolutionDir)Ruby$(Configuration).rb" file wrong..You will get complaints about VS not finding debug symbols for SketchUp. You can ignore that. for mscms.dll, that's a MS component. If you enable the Microsoft Symbols Server it will load most of the PDBs:
-
@jolran said:
@unknownuser said:
Btw guys, have you heard of DevCamp we're doing in Greece at the end of September?
Ahhh, Greece. Man, that would have been nice...
You can't make it?
-
@unknownuser said:
Visual Studio Express editions are free. Are you using any features in Ultimate which Express doesn't have? (VS2013 is really nice - I like it so much more than VS2010.)
And using the Test Explorer with the Google Runner extensions is also very nice for setting up unit tests.Ah, dang! I just looked it up, it's allowed to do commersial products with the express-version. Well, that's good to know though in any case.
I'm not bound to any features. This all for Sketchup development.
I might try 2013 later. It took quite a while to install 2010 and not without hassle..@unknownuser said:
Make will work. Any version of SketchUp that support the RubyStartup argument. (I don't recall when that was added.)
Right. I actually had 2013 and 2014(beta-tester version) installed.
So I can link to those.@unknownuser said:
You will get complaints about VS not finding debug symbols for SketchUp. You can ignore that. for mscms.dll, that's a MS component. If you enable the Microsoft Symbols Server it will load most of the PDBs:
Great! 1 step closer. I still get the PDB complaint but later, but VS seams to be loading a lot of symbols in the background now.
Should I locate the project directory in the "symbol pdb locations" ?
I don't know what I doing..@unknownuser said:
Ahhh, Greece. Man, that would have been nice...
You can't make it?
Doubt it. This "programming lifestyle" is limiting my budget.
-
I'm noticing a lot of features lacking in 2010 the more I get into it. So I installed VS 2013.
(It's quite annoying working with the lack of stl initiallizers in 2010 btw)Indeed I get a conversion promt when starting up Hello_world Project.
So I did convert.Thomthom, you said one should alter the Ruby headers.
Can I have some more info on that? I assume we are talking about ruby.h file included in external dependancies ? Or do you mean doing changes in the project properties.
In any case I'm a bit lost..Sorry about the noob questions
-
@jolran said:
Thomthom, you said one should alter the Ruby headers.
Can I have some more info on that? I assume we are talking about ruby.h file included in external dependancies ? Or do you mean doing changes in the project properties.
In any case I'm a bit lost..Yes, ruby.h and/or config.h. I don't recall exactly right now. But if I recall, one of the things where that Ruby define a "inline" macro that conflicts with VS2013.
@jolran said:
Sorry about the noob questions
No worries! I just learned this stuff myself and it's only due to my great colleagues helping me along. I'm still learning.
I'll try to go through the upgrade process again and make notes to what I had to change.
-
Check out the VS2013 branch in my private fork:
https://github.com/thomthom/ruby-c-extension-examples/tree/VS2013I just checked in a commit with some changes that should make it compile.
https://github.com/thomthom/ruby-c-extension-examples/commit/0d4090d47fc563754b57efcc003114e3973cabc7There might be other changes required as you pull in more libraries though.
-
Exellent!!
@unknownuser said:
But if I recall, one of the things where that Ruby define a "inline" macro that conflicts with VS2013.
Yeah, that's exactly what's happening. That also leads to hundreds of other sub-error messages.
I give it a try and report back!
Thanks again.
-
It worked! To make it simple for myself, I just launched your version..
I can now launch the debugger and Sketchup's correct version launch, all good to go.Just some rookie notes: (things that may be taken for granted by proffesionals )
- Working with the ruby console in debugg-mode, theres no need to require the module. Just call the C-extension functions.
* To switch release-version go into Configuration Manager (See pic below). One might think changing Release from 2.0 to 1.8 in the dropdown meny changes the project settings, But it don't(?). Not for me it diden't..EDIT: Scratch that. It worked after a project clean.
Thanks a million Thomthom!! Now it's only the small detail of adding code, left to do.
-
@jolran said:
Just some rookie notes: (things that may be taken for granted by proffesionals )
- Working with the ruby console in debugg-mode, theres no need to require the module. Just call the C-extension functions.
That's due to how the project is set up to launch SketchUp with the loading-helper that loads the extension. It's not automatic unless you configured the project to do so.
We need to add more info for the project. Please fill out issues on the GitHub bug tracker to help us keep track of this.@jolran said:
- To switch release-version go into Configuration Manager (See pic below). One might think changing Release from 2.0 to 1.8 in the dropdown meny changes the project settings, But it don't(?). Not for me it diden't..
When you change from the drop down menu that will change what is built. In order to build multiple go BUILT > Batch Build
-
Ah, post edited...
-
Yeah, sorry about that.
I was to exited. -
I might have mucked up the debug config with that VS2013 branch... Just looked at the diff of changes and something looks amiss. Just so you are aware.
I'm not sure I have time until next week to look into that. -
Ok, thanks for telling.
I havent tested it much yet. Will dig in more intensly after the weekend.
Anyway it seams to be working correctly when just calling functions from the C module in the Ruby console. -
So I finally managed to bring in 100 000 points convert them to C++ class and then convert back to Sketchup Point3d objects.
Timing the response back in Alex S-Ruby console clocks ~ 0.50 which is amazingly fast.
Did some other tests, bloody hell it's blitz..However if I clock a new "puts time" in the row after the C -callback. it gets increasingly
slower for each C-functioncall.
C-callback response still clocks about the same each time..Is it the Ruby garbage collector running ? Adding this amount of points aught to slow Sketchup down, I know..
So I take it one cannot rely on C-response when things are "ready" to go forth in Ruby ?
For ex if I expect an array as responce will there be an error in following code.
Or does not following code execute until the array is ready ?
(havent tested stuff on so many points yet)I don't think I'm creating a memory leak in C++ since I have seen the destructor activate during some tests. And this test is done within 1 function so.. Points in points out..
Note: I did this in debug-mode(SU 2013), so maybe that affects threading or something.
Advertisement