On 20/05/2015 at 18:46, xxxxxxxx wrote:
Hi Monkeytack,
I know, it genuinely does sound unbelievable. Looking back over my results and stepping back through my code it is not QUITE comparing like for like, because each time i refactored some code it might have a knock on effect and i was doing quite a lot of refactoring from rough proof of concept code with SMC to much more optimised routines with the Modeling library..
So with that said, these are the numbers i was getting as i progressed through the code, refactoring things as i went along:
TOTAL TIME [0] Clone Object : 116.997
TOTAL TIME [1] Selection : 0.147
TOTAL TIME [2] Expand Selection : 84.621
TOTAL TIME [3] Expand+Toggle : 59.416
TOTAL TIME [4] DeletePoints : 4709.945
TOTAL TIME [5] Selection Copying : 0.086
TOTAL TIME [6] SUBDIVIDE : 198.487
TOTAL TIME [7] Invert+Delete : 339.949
----------------------------------------
TOTAL TIME [0]: 130.604
TOTAL TIME [1]: 0.147
TOTAL TIME [2]: 61.658
TOTAL TIME [3]: 52.876
TOTAL TIME [4]: 1.595 ( DELETE POLYS with MODELING LIB )
TOTAL TIME [5]: 0.719
TOTAL TIME [6]: 1226.877
TOTAL TIME [7]: 14430.343
-----------------------------------------------
TOTAL TIME [0]: 140.582
TOTAL TIME [1]: 0.168
TOTAL TIME [2]: 62.127
TOTAL TIME [3]: 53.323
TOTAL TIME [4]: 1.382 ( DELETE POINTS with MODELING LIB )
TOTAL TIME [5]: 0.792
TOTAL TIME [6]: 1226.605
TOTAL TIME [7]: 0.081 ( DELETE POLYS with MODELING LIB )
-----------------------------------------------
TOTAL TIME [0]: 134.465
TOTAL TIME [1]: 0.205
TOTAL TIME [2]: 76.892
TOTAL TIME [3]: 5.25 ( DELETE POLYS with MODELING LIB )
TOTAL TIME [4]: 0.011 ( DELETE POINTS with MODELING LIB )
TOTAL TIME [5]: 0.767
TOTAL TIME [6]: 1178.104
TOTAL TIME [7]: 0.071 ( DELETE POLYS with MODELING LIB )
-----------------------------------------------
TOTAL TIME [0]: 204.797
TOTAL TIME [1]: 0.857
TOTAL TIME [2]: 5.171 ( EXPAND SELECTION with MODELING LIB )
TOTAL TIME [3]: 0.024 ( DELETE POLYS with MODELING LIB )
TOTAL TIME [4]: 0.008 ( DELETE POINTS with MODELING LIB )
TOTAL TIME [5]: 0.791
TOTAL TIME [6]: 1113.044
TOTAL TIME [7]: 0.07 ( DELETE POLYS with MODELING LIB )
-----------------------------------------------
These TOTAL TIME numbers are the accumulation of each chunk of code running on 12 separate threads, added together ( not averaged ). The knock on effect can be seen as i change one part the next part might jump up considerably ( possibly due to switching from point to poly selections/ops or from a greater number of points/polys being passed down the chain ). But still, massively substantial gains were got from going from what was pretty much a chain of SendModelingCommand's with lots of BaseSelect stuff inbetween, to more optimised Modeling class and similar code..
For the MCOMMAND_DELETE parts, basically i went from for example:
// Delete Outer Points
pointSel->ToggleAll(0,clone->GetPointCount());
ModelingCommandData cd3;
cd3.doc = doc;
cd3.op = clone;
cd3.mode = MODELINGCOMMANDMODE_POINTSELECTION;
SendModelingCommand(MCOMMAND_DELETE, cd3);
To the following:
// Delete Outer Points - left with Fragment+
mod || !mod->InitObject(clone);
pointSel->ToggleAll(0,clone->GetPointCount());
while (pointSel->GetRange(seg++,MAXLONGl,&a,&b))
{
for (i=a; i<=b; ++i)
{
if (i>=pIndexStart && i<LONG(pLength+pIndexStart))
{
mod->DeletePoint(clone,i);
}
}
}
mod->Commit();
This is all C++ code of course, but the Python equivalents aren't too different..
Also my initial attempt at speeding up the object Cloning looked like the following but was a bit slower than just using ->GetClone(COPYFLAGS_0,NULL) so will have to look at that some more:
//PolygonObject *clone = ToPoly(op->GetClone(COPYFLAGS_0, NULL));
LONG pcnt = op->GetPointCount(),vcnt = op->GetPolygonCount();
AutoAlloc<PolygonObject> clone(pcnt,vcnt);
c4d_misc::BaseArray<LONG> pointindex;
c4d_misc::BaseArray<Ngon> polies;
const CPolygon *cpolyOP = op->GetPolygonR();
CPolygon *cpolyCLONE = clone->GetPolygonW();
for (i=0; i<vcnt; i++)
{
for (j=0;j<4;j++)
{
cpolyCLONE[i][j] = cpolyOP[i][j];
}
}
PS - The TOTAL TIME value above for DeletePoints at 4000+, i have no idea now why that was so high on that earlier run ( i did use the same test document throughout ) but the numbers were copy/pasted directly from the Console, so it did happen! But either way it can be seen elsewhere in the numbers where huge time savings have been made..
PSPS - Please excuse any typos or mistakes in any of the above, i'm exposing my maverick coding style here - i do generally end up with nice clean code in the end 