[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12680] branches/cloth/blender/intern/ elbeem/intern/isosurface.cpp: Code got unreadble due to copy-paste ( hint for me: revert point)

Daniel Genrich daniel.genrich at gmx.net
Mon Nov 26 15:59:58 CET 2007


Revision: 12680
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12680
Author:   genscher
Date:     2007-11-26 15:59:58 +0100 (Mon, 26 Nov 2007)

Log Message:
-----------
Code got unreadble due to copy-paste (hint for me: revert point)

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 14:50:27 UTC (rev 12679)
+++ branches/cloth/blender/intern/elbeem/intern/isosurface.cpp	2007-11-26 14:59:58 UTC (rev 12680)
@@ -18,28 +18,32 @@
 #define round(x) (x)
 #endif
 
+#if PARALLEL==1	
+#include <omp.h>
+#endif
+
 /******************************************************************************
  * Constructor
  *****************************************************************************/
 IsoSurface::IsoSurface(double iso) :
-		ntlGeometryObject(),
-				  mSizex(-1), mSizey(-1), mSizez(-1),
-					  mpData(NULL),
-							  mIsoValue( iso ), 
-									  mPoints(), 
-										mUseFullEdgeArrays(false),
-										mpEdgeVerticesX(NULL), mpEdgeVerticesY(NULL), mpEdgeVerticesZ(NULL),
-										mEdgeArSize(-1),
-										mIndices(),
+	ntlGeometryObject(),
+	mSizex(-1), mSizey(-1), mSizez(-1),
+	mpData(NULL),
+  mIsoValue( iso ), 
+	mPoints(), 
+	mUseFullEdgeArrays(false),
+	mpEdgeVerticesX(NULL), mpEdgeVerticesY(NULL), mpEdgeVerticesZ(NULL),
+	mEdgeArSize(-1),
+	mIndices(),
 
-										mStart(0.0), mEnd(0.0), mDomainExtent(0.0),
-										mInitDone(false),
-										mSmoothSurface(0.0), mSmoothNormals(0.0),
-										mAcrossEdge(), mAdjacentFaces(),
-										mCutoff(-1), mCutArray(NULL), // off by default
-										mpIsoParts(NULL), mPartSize(0.), mSubdivs(0),
-										mFlagCnt(1),
-										mSCrad1(0.), mSCrad2(0.), mSCcenter(0.)
+  mStart(0.0), mEnd(0.0), mDomainExtent(0.0),
+  mInitDone(false),
+	mSmoothSurface(0.0), mSmoothNormals(0.0),
+	mAcrossEdge(), mAdjacentFaces(),
+	mCutoff(-1), mCutArray(NULL), // off by default
+	mpIsoParts(NULL), mPartSize(0.), mSubdivs(0),
+	mFlagCnt(1),
+	mSCrad1(0.), mSCrad2(0.), mSCcenter(0.)
 {
 }
 
@@ -71,11 +75,11 @@
 
   // init 
 	mIndices.clear();
-	mPoints.clear();
+  mPoints.clear();
 
 	int nodes = mSizez*mSizey*mSizex;
-	mpData = new float[nodes];
-	for(int i=0;i<nodes;i++) { mpData[i] = 0.0; }
+  mpData = new float[nodes];
+  for(int i=0;i<nodes;i++) { mpData[i] = 0.0; }
 
   // allocate edge arrays  (last slices are never used...)
 	int initsize = -1;
@@ -93,7 +97,7 @@
 		mpEdgeVerticesZ = new int[sliceNodes];
 		initsize = 3*sliceNodes;
 	}
-	for(int i=0;i<mEdgeArSize;i++) { mpEdgeVerticesX[i] = mpEdgeVerticesY[i] = mpEdgeVerticesZ[i] = -1; }
+  for(int i=0;i<mEdgeArSize;i++) { mpEdgeVerticesX[i] = mpEdgeVerticesY[i] = mpEdgeVerticesZ[i] = -1; }
 	// WARNING - make sure this is consistent with calculateMemreqEstimate
   
 	// marching cubes are ready 
@@ -106,7 +110,7 @@
 /*! Reset all values */
 void IsoSurface::resetAll(gfxReal val) {
 	int nodes = mSizez*mSizey*mSizex;
-	for(int i=0;i<nodes;i++) { mpData[i] = val; }
+  for(int i=0;i<nodes;i++) { mpData[i] = val; }
 }
 
 
@@ -130,9 +134,9 @@
  *****************************************************************************/
 void IsoSurface::triangulate( void )
 {
-	double gsx,gsy,gsz; // grid spacing in x,y,z direction
-	double px,py,pz;    // current position in grid in x,y,z direction
-  // IsoLevelCube cubie;    // struct for a small subcube
+  double gsx,gsy,gsz; // grid spacing in x,y,z direction
+  double px,py,pz;    // current position in grid in x,y,z direction
+  IsoLevelCube cubie;    // struct for a small subcube
 	myTime_t tritimestart = getTime(); 
 
 	if(!mpData) {
@@ -141,16 +145,16 @@
 	}
 
   // get grid spacing (-2 to have same spacing as sim)
-	gsx = (mEnd[0]-mStart[0])/(double)(mSizex-2.0);
-	gsy = (mEnd[1]-mStart[1])/(double)(mSizey-2.0);
-	gsz = (mEnd[2]-mStart[2])/(double)(mSizez-2.0);
+  gsx = (mEnd[0]-mStart[0])/(double)(mSizex-2.0);
+  gsy = (mEnd[1]-mStart[1])/(double)(mSizey-2.0);
+  gsz = (mEnd[2]-mStart[2])/(double)(mSizez-2.0);
 
   // clean up previous frame
 	mIndices.clear();
 	mPoints.clear();
 
 	// reset edge vertices
-	for(int i=0;i<mEdgeArSize;i++) {
+  for(int i=0;i<mEdgeArSize;i++) {
 		mpEdgeVerticesX[i] = -1;
 		mpEdgeVerticesY[i] = -1;
 		mpEdgeVerticesZ[i] = -1;
@@ -159,418 +163,421 @@
 	// edges between which points?
 	const int mcEdges[24] = { 
 		0,1,  1,2,  2,3,  3,0,
-  4,5,  5,6,  6,7,  7,4,
-  0,4,  1,5,  2,6,  3,7 };
+		4,5,  5,6,  6,7,  7,4,
+		0,4,  1,5,  2,6,  3,7 };
 
-  const int cubieOffsetX[8] = {
-	  0,1,1,0,  0,1,1,0 };
-	  const int cubieOffsetY[8] = {
-		  0,0,1,1,  0,0,1,1 };
-		  const int cubieOffsetZ[8] = {
-			  0,0,0,0,  1,1,1,1 };
+	const int cubieOffsetX[8] = {
+		0,1,1,0,  0,1,1,0 };
+	const int cubieOffsetY[8] = {
+		0,0,1,1,  0,0,1,1 };
+	const int cubieOffsetZ[8] = {
+		0,0,0,0,  1,1,1,1 };
 
-			  const int coAdd=2;
+	const int coAdd=2;
   // let the cubes march 
-			  if(mSubdivs<=1) {
+	if(mSubdivs<=1) {
 
-				  pz = mStart[2]-gsz*0.5;
-				  for(int k=1;k<(mSizez-2);k++) {
-					  pz += gsz;
-					  py = mStart[1]-gsy*0.5;
-					  for(int j=1;j<(mSizey-2);j++) {
-						  py += gsy;
-						  px = mStart[0]-gsx*0.5;
-						  for(int i=1;i<(mSizex-2);i++) {
-							  px += gsx;
-							  int cubeIndex;      // index entry of the cube 
-							  float value[8];
-							  int triIndices[12]; // vertex indices 
-							  int *eVert[12];
-							  IsoLevelVertex ilv;
+		pz = mStart[2]-gsz*0.5;
+		for(int k=1;k<(mSizez-2);k++) {
+			pz += gsz;
+			py = mStart[1]-gsy*0.5;
+			for(int j=1;j<(mSizey-2);j++) {
+				py += gsy;
+				px = mStart[0]-gsx*0.5;
+				for(int i=1;i<(mSizex-2);i++) {
+					px += gsx;
+					int cubeIndex;      // index entry of the cube 
+					float value[8];
+					int triIndices[12]; // vertex indices 
+					int *eVert[12];
+					IsoLevelVertex ilv;
 					
-							  value[0] = *getData(i  ,j  ,k  );
-							  value[1] = *getData(i+1,j  ,k  );
-							  value[2] = *getData(i+1,j+1,k  );
-							  value[3] = *getData(i  ,j+1,k  );
-							  value[4] = *getData(i  ,j  ,k+1);
-							  value[5] = *getData(i+1,j  ,k+1);
-							  value[6] = *getData(i+1,j+1,k+1);
-							  value[7] = *getData(i  ,j+1,k+1);
+					value[0] = *getData(i  ,j  ,k  );
+					value[1] = *getData(i+1,j  ,k  );
+					value[2] = *getData(i+1,j+1,k  );
+					value[3] = *getData(i  ,j+1,k  );
+					value[4] = *getData(i  ,j  ,k+1);
+					value[5] = *getData(i+1,j  ,k+1);
+					value[6] = *getData(i+1,j+1,k+1);
+					value[7] = *getData(i  ,j+1,k+1);
 
 					// check intersections of isosurface with edges, and calculate cubie index
-							  cubeIndex = 0;
-							  if (value[0] < mIsoValue) cubeIndex |= 1;
-							  if (value[1] < mIsoValue) cubeIndex |= 2;
-							  if (value[2] < mIsoValue) cubeIndex |= 4;
-							  if (value[3] < mIsoValue) cubeIndex |= 8;
-							  if (value[4] < mIsoValue) cubeIndex |= 16;
-							  if (value[5] < mIsoValue) cubeIndex |= 32;
-							  if (value[6] < mIsoValue) cubeIndex |= 64;
-							  if (value[7] < mIsoValue) cubeIndex |= 128;
+					cubeIndex = 0;
+					if (value[0] < mIsoValue) cubeIndex |= 1;
+					if (value[1] < mIsoValue) cubeIndex |= 2;
+					if (value[2] < mIsoValue) cubeIndex |= 4;
+					if (value[3] < mIsoValue) cubeIndex |= 8;
+					if (value[4] < mIsoValue) cubeIndex |= 16;
+					if (value[5] < mIsoValue) cubeIndex |= 32;
+					if (value[6] < mIsoValue) cubeIndex |= 64;
+					if (value[7] < mIsoValue) cubeIndex |= 128;
 
 					// No triangles to generate?
-							  if (mcEdgeTable[cubeIndex] == 0) {
-								  continue;
-							  }
+					if (mcEdgeTable[cubeIndex] == 0) {
+						continue;
+					}
 
 					// where to look up if this point already exists
-							  int edgek = 0;
-							  if(mUseFullEdgeArrays) edgek=k;
-							  const int baseIn = ISOLEVEL_INDEX( i+0, j+0, edgek+0);
-							  eVert[ 0] = &mpEdgeVerticesX[ baseIn ];
-							  eVert[ 1] = &mpEdgeVerticesY[ baseIn + 1 ];
-							  eVert[ 2] = &mpEdgeVerticesX[ ISOLEVEL_INDEX( i+0, j+1, edgek+0) ];
-							  eVert[ 3] = &mpEdgeVerticesY[ baseIn ];
+					int edgek = 0;
+					if(mUseFullEdgeArrays) edgek=k;
+					const int baseIn = ISOLEVEL_INDEX( i+0, j+0, edgek+0);
+					eVert[ 0] = &mpEdgeVerticesX[ baseIn ];
+					eVert[ 1] = &mpEdgeVerticesY[ baseIn + 1 ];
+					eVert[ 2] = &mpEdgeVerticesX[ ISOLEVEL_INDEX( i+0, j+1, edgek+0) ];
+					eVert[ 3] = &mpEdgeVerticesY[ baseIn ];
 
-							  eVert[ 4] = &mpEdgeVerticesX[ ISOLEVEL_INDEX( i+0, j+0, edgek+1) ];
-							  eVert[ 5] = &mpEdgeVerticesY[ ISOLEVEL_INDEX( i+1, j+0, edgek+1) ];
-							  eVert[ 6] = &mpEdgeVerticesX[ ISOLEVEL_INDEX( i+0, j+1, edgek+1) ];
-							  eVert[ 7] = &mpEdgeVerticesY[ ISOLEVEL_INDEX( i+0, j+0, edgek+1) ];
+					eVert[ 4] = &mpEdgeVerticesX[ ISOLEVEL_INDEX( i+0, j+0, edgek+1) ];
+					eVert[ 5] = &mpEdgeVerticesY[ ISOLEVEL_INDEX( i+1, j+0, edgek+1) ];
+					eVert[ 6] = &mpEdgeVerticesX[ ISOLEVEL_INDEX( i+0, j+1, edgek+1) ];
+					eVert[ 7] = &mpEdgeVerticesY[ ISOLEVEL_INDEX( i+0, j+0, edgek+1) ];
 
-							  eVert[ 8] = &mpEdgeVerticesZ[ baseIn ];
-							  eVert[ 9] = &mpEdgeVerticesZ[ ISOLEVEL_INDEX( i+1, j+0, edgek+0) ];
-							  eVert[10] = &mpEdgeVerticesZ[ ISOLEVEL_INDEX( i+1, j+1, edgek+0) ];
-							  eVert[11] = &mpEdgeVerticesZ[ ISOLEVEL_INDEX( i+0, j+1, edgek+0) ];
+					eVert[ 8] = &mpEdgeVerticesZ[ baseIn ];
+					eVert[ 9] = &mpEdgeVerticesZ[ ISOLEVEL_INDEX( i+1, j+0, edgek+0) ];
+					eVert[10] = &mpEdgeVerticesZ[ ISOLEVEL_INDEX( i+1, j+1, edgek+0) ];
+					eVert[11] = &mpEdgeVerticesZ[ ISOLEVEL_INDEX( i+0, j+1, edgek+0) ];
 
 					// grid positions
-							  ntlVec3Gfx pos[8];
-							  pos[0] = ntlVec3Gfx(px    ,py    ,pz);
-							  pos[1] = ntlVec3Gfx(px+gsx,py    ,pz);
-							  pos[2] = ntlVec3Gfx(px+gsx,py+gsy,pz);
-							  pos[3] = ntlVec3Gfx(px    ,py+gsy,pz);
-							  pos[4] = ntlVec3Gfx(px    ,py    ,pz+gsz);
-							  pos[5] = ntlVec3Gfx(px+gsx,py    ,pz+gsz);
-							  pos[6] = ntlVec3Gfx(px+gsx,py+gsy,pz+gsz);
-							  pos[7] = ntlVec3Gfx(px    ,py+gsy,pz+gsz);
+					ntlVec3Gfx pos[8];
+					pos[0] = ntlVec3Gfx(px    ,py    ,pz);
+					pos[1] = ntlVec3Gfx(px+gsx,py    ,pz);
+					pos[2] = ntlVec3Gfx(px+gsx,py+gsy,pz);
+					pos[3] = ntlVec3Gfx(px    ,py+gsy,pz);
+					pos[4] = ntlVec3Gfx(px    ,py    ,pz+gsz);
+					pos[5] = ntlVec3Gfx(px+gsx,py    ,pz+gsz);
+					pos[6] = ntlVec3Gfx(px+gsx,py+gsy,pz+gsz);
+					pos[7] = ntlVec3Gfx(px    ,py+gsy,pz+gsz);
 
 					// check all edges
-							  for(int e=0;e<12;e++) {
-								  if (mcEdgeTable[cubeIndex] & (1<<e)) {
+					for(int e=0;e<12;e++) {
+						if (mcEdgeTable[cubeIndex] & (1<<e)) {
 							// is the vertex already calculated?
-									  if(*eVert[ e ] < 0) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list