[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12674] branches/cloth/blender/intern/ elbeem/intern/isosurface.cpp: Insert revert point (segfault)
Daniel Genrich
daniel.genrich at gmx.net
Mon Nov 26 01:57:46 CET 2007
Revision: 12674
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12674
Author: genscher
Date: 2007-11-26 01:57:46 +0100 (Mon, 26 Nov 2007)
Log Message:
-----------
Insert revert point (segfault)
Modified Paths:
--------------
branches/cloth/blender/intern/elbeem/intern/isosurface.cpp
Modified: branches/cloth/blender/intern/elbeem/intern/isosurface.cpp
===================================================================
--- branches/cloth/blender/intern/elbeem/intern/isosurface.cpp 2007-11-26 00:26:29 UTC (rev 12673)
+++ branches/cloth/blender/intern/elbeem/intern/isosurface.cpp 2007-11-26 00:57:46 UTC (rev 12674)
@@ -18,6 +18,8 @@
#define round(x) (x)
#endif
+#include <omp.h>
+
/******************************************************************************
* Constructor
*****************************************************************************/
@@ -400,17 +402,28 @@
debMsgStd("IsoSurface::triangulate",DM_MSG,"Starting. Parts in use:"<<pInUse<<", Subdivs:"<<mSubdivs, 9);
pz = mStart[2]-(double)(0.*gsz)-0.5*orgGsz;
-/*
+
#pragma omp parallel
{
- vector<IsoLevelVertex> mPoints;
- */
-#pragma omp parallel for
+ vector<IsoLevelVertex> calcPoints;
+ vector<unsigned int> calcIndices;
+ const int id = omp_get_thread_num();
+ const int Nthrds = omp_get_num_threads();
+
+ const int Nj = (mSizey-2);
+
+ int jstart = 0+( id * (Nj / Nthrds) );
+ int jend = 0+( (id+1) * (Nj / Nthrds) );
+
+ if(jstart<1) jstart = 1;
+ if(jend>(mSizey-2)) jend = (mSizey-2);
+
+
for(int ok=1;ok<(mSizez-2)*mSubdivs;ok++) {
pz += gsz;
const int k = ok/mSubdivs;
if(k<=0) continue; // skip zero plane
- for(int j=1;j<(mSizey-2);j++) {
+ for(int j=jstart;j<jend;j++) {
for(int i=1;i<(mSizex-2);i++) {
float value[8];
ntlVec3Gfx pos[8];
@@ -587,11 +600,8 @@
// init isolevel vertex
ilv.v = p1 + (p2-p1)*mu; // with subdivs
-#pragma omp critical
- {
- mPoints.push_back( ilv );
- triIndices[e] = (mPoints.size()-1);
- }
+ calcPoints.push_back( ilv );
+ triIndices[e] = (calcPoints.size()-1);
// store vertex
*eVert[ e ] = triIndices[e];
} else {
@@ -601,17 +611,15 @@
} // along all edges
}
// removed cutoff treatment...
-#pragma omp critical
- {
+
// Create the triangles...
for(int e=0; mcTriTable[cubeIndex][e]!=-1; e+=3) {
- mIndices.push_back( triIndices[ mcTriTable[cubeIndex][e+0] ] );
- mIndices.push_back( triIndices[ mcTriTable[cubeIndex][e+1] ] ); // with subdivs
- mIndices.push_back( triIndices[ mcTriTable[cubeIndex][e+2] ] );
+ calcIndices.push_back( triIndices[ mcTriTable[cubeIndex][e+0] ] );
+ calcIndices.push_back( triIndices[ mcTriTable[cubeIndex][e+1] ] ); // with subdivs
+ calcIndices.push_back( triIndices[ mcTriTable[cubeIndex][e+2] ] );
//errMsg("TTT"," i1"<<mIndices[mIndices.size()-3]<<" "<< " i2"<<mIndices[mIndices.size()-2]<<" "<< " i3"<<mIndices[mIndices.size()-1]<<" "<< mIndices.size() );
+ } // triangles in edge table?
}
- }
- } // triangles in edge table?
}//si
}// sj
@@ -640,7 +648,20 @@
} // ok, k subdiv loop
// push_back()'s
-// }
+#pragma omp critical
+ {
+ unsigned int size = mIndices.size();
+ // remap indices
+ for(unsigned int j=0; j<calcIndices.size(); j++)
+ {
+ mIndices.push_back(calcIndices[j]+size);
+ }
+ for(unsigned int j=0; j<calcPoints.size(); j++)
+ {
+ mPoints.push_back(calcPoints[j]);
+ }
+ }
+}
//delete [] subdAr;
delete [] arppnt;
More information about the Bf-blender-cvs
mailing list