[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46438] trunk/blender/intern/dualcon: Code style cleanup in intern/dualcon.
Nicholas Bishop
nicholasbishop at gmail.com
Wed May 9 00:11:05 CEST 2012
Revision: 46438
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46438
Author: nicholasbishop
Date: 2012-05-08 22:11:05 +0000 (Tue, 08 May 2012)
Log Message:
-----------
Code style cleanup in intern/dualcon.
Modified Paths:
--------------
trunk/blender/intern/dualcon/dualcon.h
trunk/blender/intern/dualcon/intern/GeoCommon.h
trunk/blender/intern/dualcon/intern/MemoryAllocator.h
trunk/blender/intern/dualcon/intern/ModelReader.h
trunk/blender/intern/dualcon/intern/Projections.cpp
trunk/blender/intern/dualcon/intern/Projections.h
trunk/blender/intern/dualcon/intern/Queue.h
trunk/blender/intern/dualcon/intern/cubes.h
trunk/blender/intern/dualcon/intern/dualcon_c_api.cpp
trunk/blender/intern/dualcon/intern/marching_cubes_table.cpp
trunk/blender/intern/dualcon/intern/octree.cpp
trunk/blender/intern/dualcon/intern/octree.h
Modified: trunk/blender/intern/dualcon/dualcon.h
===================================================================
--- trunk/blender/intern/dualcon/dualcon.h 2012-05-08 22:07:06 UTC (rev 46437)
+++ trunk/blender/intern/dualcon/dualcon.h 2012-05-08 22:11:05 UTC (rev 46438)
@@ -24,7 +24,7 @@
#define __DUALCON_H__
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
typedef float (*DualConCo)[3];
@@ -35,11 +35,11 @@
DualConCo co;
int co_stride;
int totco;
-
+
DualConFaces faces;
int face_stride;
int totface;
-
+
float min[3], max[3];
} DualConInput;
@@ -64,32 +64,32 @@
} DualConMode;
/* Usage:
-
- The three callback arguments are used for creating the output
- mesh. The alloc_output callback takes the total number of vertices
- and faces (quads) that will be in the output. It should allocate
- and return a structure to hold the output mesh. The add_vert and
- add_quad callbacks will then be called for each new vertex and
- quad, and the callback should add the new mesh elements to the
- structure.
-*/
+ *
+ * The three callback arguments are used for creating the output
+ * mesh. The alloc_output callback takes the total number of vertices
+ * and faces (quads) that will be in the output. It should allocate
+ * and return a structure to hold the output mesh. The add_vert and
+ * add_quad callbacks will then be called for each new vertex and
+ * quad, and the callback should add the new mesh elements to the
+ * structure.
+ */
void *dualcon(const DualConInput *input_mesh,
- /* callbacks for output */
- DualConAllocOutput alloc_output,
- DualConAddVert add_vert,
- DualConAddQuad add_quad,
+ /* callbacks for output */
+ DualConAllocOutput alloc_output,
+ DualConAddVert add_vert,
+ DualConAddQuad add_quad,
- /* flags and settings to control the remeshing
- algorithm */
- DualConFlags flags,
- DualConMode mode,
- float threshold,
- float hermite_num,
- float scale,
- int depth);
+ /* flags and settings to control the remeshing
+ * algorithm */
+ DualConFlags flags,
+ DualConMode mode,
+ float threshold,
+ float hermite_num,
+ float scale,
+ int depth);
#ifdef __cplusplus
-}
+}
#endif
#endif /* __DUALCON_H__ */
Modified: trunk/blender/intern/dualcon/intern/GeoCommon.h
===================================================================
--- trunk/blender/intern/dualcon/intern/GeoCommon.h 2012-05-08 22:07:06 UTC (rev 46437)
+++ trunk/blender/intern/dualcon/intern/GeoCommon.h 2012-05-08 22:11:05 UTC (rev 46438)
@@ -36,31 +36,26 @@
// 3d point with integer coordinates
-typedef struct
-{
+typedef struct {
int x, y, z;
} Point3i;
-typedef struct
-{
+typedef struct {
Point3i begin;
Point3i end;
} BoundingBox;
// triangle that points to three vertices
-typedef struct
-{
- float vt[3][3] ;
+typedef struct {
+ float vt[3][3];
} Triangle;
// 3d point with float coordinates
-typedef struct
-{
+typedef struct {
float x, y, z;
} Point3f;
-typedef struct
-{
+typedef struct {
Point3f begin;
Point3f end;
} BoundingBoxf;
Modified: trunk/blender/intern/dualcon/intern/MemoryAllocator.h
===================================================================
--- trunk/blender/intern/dualcon/intern/MemoryAllocator.h 2012-05-08 22:07:06 UTC (rev 46437)
+++ trunk/blender/intern/dualcon/intern/MemoryAllocator.h 2012-05-08 22:11:05 UTC (rev 46438)
@@ -43,19 +43,19 @@
class VirtualMemoryAllocator
{
public:
- virtual void * allocate( ) = 0 ;
- virtual void deallocate( void * obj ) = 0 ;
- virtual void destroy( ) = 0 ;
- virtual void printInfo( ) = 0 ;
+virtual void *allocate( ) = 0;
+virtual void deallocate(void *obj) = 0;
+virtual void destroy( ) = 0;
+virtual void printInfo( ) = 0;
- virtual int getAllocated( ) = 0 ;
- virtual int getAll( ) = 0 ;
- virtual int getBytes( ) = 0 ;
+virtual int getAllocated( ) = 0;
+virtual int getAll( ) = 0;
+virtual int getBytes( ) = 0;
};
/**
* Dynamic memory allocator - allows allocation/deallocation
- *
+ *
* Note: there are 4 bytes overhead for each allocated yet unused object.
*/
template < int N >
@@ -63,157 +63,157 @@
{
private:
- /// Constants
- int HEAP_UNIT, HEAP_MASK ;
+/// Constants
+int HEAP_UNIT, HEAP_MASK;
- /// Data array
- UCHAR ** data ;
+/// Data array
+UCHAR **data;
- /// Allocation stack
- UCHAR *** stack ;
+/// Allocation stack
+UCHAR ***stack;
- /// Number of data blocks
- int datablocknum ;
+/// Number of data blocks
+int datablocknum;
- /// Number of stack blocks
- int stackblocknum ;
+/// Number of stack blocks
+int stackblocknum;
- /// Size of stack
- int stacksize ;
+/// Size of stack
+int stacksize;
- /// Number of available objects on stack
- int available ;
+/// Number of available objects on stack
+int available;
- /**
- * Allocate a memory block
- */
- void allocateDataBlock ( )
- {
- // Allocate a data block
- datablocknum += 1 ;
- data = ( UCHAR ** )realloc( data, sizeof ( UCHAR * ) * datablocknum ) ;
- data[ datablocknum - 1 ] = ( UCHAR * )malloc( HEAP_UNIT * N ) ;
+/**
+ * Allocate a memory block
+ */
+void allocateDataBlock( )
+{
+ // Allocate a data block
+ datablocknum += 1;
+ data = ( UCHAR ** )realloc(data, sizeof (UCHAR *) * datablocknum);
+ data[datablocknum - 1] = ( UCHAR * )malloc(HEAP_UNIT * N);
- // Update allocation stack
- for ( int i = 0 ; i < HEAP_UNIT ; i ++ )
- {
- stack[ 0 ][ i ] = ( data[ datablocknum - 1 ] + i * N ) ;
- }
- available = HEAP_UNIT ;
- }
-
- /**
- * Allocate a stack block, to store more deallocated objects
- */
- void allocateStackBlock( )
+ // Update allocation stack
+ for (int i = 0; i < HEAP_UNIT; i++)
{
- // Allocate a stack block
- stackblocknum += 1 ;
- stacksize += HEAP_UNIT ;
- stack = ( UCHAR *** )realloc( stack, sizeof ( UCHAR ** ) * stackblocknum ) ;
- stack[ stackblocknum - 1 ] = ( UCHAR ** )malloc( HEAP_UNIT * sizeof ( UCHAR * ) ) ;
+ stack[0][i] = (data[datablocknum - 1] + i * N);
}
+ available = HEAP_UNIT;
+}
+/**
+ * Allocate a stack block, to store more deallocated objects
+ */
+void allocateStackBlock( )
+{
+ // Allocate a stack block
+ stackblocknum += 1;
+ stacksize += HEAP_UNIT;
+ stack = ( UCHAR *** )realloc(stack, sizeof (UCHAR * *) * stackblocknum);
+ stack[stackblocknum - 1] = ( UCHAR ** )malloc(HEAP_UNIT * sizeof (UCHAR *) );
+}
+
public:
- /**
- * Constructor
- */
- MemoryAllocator( )
- {
- HEAP_UNIT = 1 << HEAP_BASE ;
- HEAP_MASK = ( 1 << HEAP_BASE ) - 1 ;
+/**
+ * Constructor
+ */
+MemoryAllocator( )
+{
+ HEAP_UNIT = 1 << HEAP_BASE;
+ HEAP_MASK = (1 << HEAP_BASE) - 1;
- data = ( UCHAR ** )malloc( sizeof( UCHAR * ) ) ;
- data[ 0 ] = ( UCHAR * )malloc( HEAP_UNIT * N ) ;
- datablocknum = 1 ;
+ data = ( UCHAR ** )malloc(sizeof(UCHAR *) );
+ data[0] = ( UCHAR * )malloc(HEAP_UNIT * N);
+ datablocknum = 1;
- stack = ( UCHAR *** )malloc( sizeof ( UCHAR ** ) ) ;
- stack[ 0 ] = ( UCHAR ** )malloc( HEAP_UNIT * sizeof ( UCHAR * ) ) ;
- stackblocknum = 1 ;
- stacksize = HEAP_UNIT ;
- available = HEAP_UNIT ;
+ stack = ( UCHAR *** )malloc(sizeof (UCHAR * *) );
+ stack[0] = ( UCHAR ** )malloc(HEAP_UNIT * sizeof (UCHAR *) );
+ stackblocknum = 1;
+ stacksize = HEAP_UNIT;
+ available = HEAP_UNIT;
- for ( int i = 0 ; i < HEAP_UNIT ; i ++ )
- {
- stack[ 0 ][ i ] = ( data[ 0 ] + i * N ) ;
- }
+ for (int i = 0; i < HEAP_UNIT; i++)
+ {
+ stack[0][i] = (data[0] + i * N);
}
+}
- /**
- * Destructor
- */
- void destroy( )
+/**
+ * Destructor
+ */
+void destroy( )
+{
+ int i;
+ for (i = 0; i < datablocknum; i++)
{
- int i ;
- for ( i = 0 ; i < datablocknum ; i ++ )
- {
- free( data[ i ] ) ;
- }
- for ( i = 0 ; i < stackblocknum ; i ++ )
- {
- free( stack[ i ] ) ;
- }
- free( data ) ;
- free( stack ) ;
+ free(data[i]);
}
-
- /**
- * Allocation method
- */
- void * allocate ( )
+ for (i = 0; i < stackblocknum; i++)
{
- if ( available == 0 )
- {
- allocateDataBlock ( ) ;
- }
-
- // printf("Allocating %d\n", header[ allocated ]) ;
- available -- ;
- return (void*)stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] ;
+ free(stack[i]);
}
+ free(data);
+ free(stack);
+}
- /**
- * De-allocation method
- */
- void deallocate ( void * obj )
+/**
+ * Allocation method
+ */
+void *allocate( )
+{
+ if (available == 0)
{
- if ( available == stacksize )
- {
- allocateStackBlock ( ) ;
- }
-
- // printf("De-allocating %d\n", ( obj - data ) / N ) ;
- stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] = (UCHAR*)obj ;
- available ++ ;
- // printf("%d %d\n", allocated, header[ allocated ]) ;
+ allocateDataBlock( );
}
- /**
- * Print information
- */
- void printInfo ( )
+ // printf("Allocating %d\n", header[ allocated ]) ;
+ available--;
+ return (void *)stack[available >> HEAP_BASE][available & HEAP_MASK];
+}
+
+/**
+ * De-allocation method
+ */
+void deallocate(void *obj)
+{
+ if (available == stacksize)
{
- printf("Bytes: %d Used: %d Allocated: %d Maxfree: %d\n", getBytes(), getAllocated(), getAll(), stacksize ) ;
+ allocateStackBlock( );
}
- /**
- * Query methods
- */
- int getAllocated( )
- {
- return HEAP_UNIT * datablocknum - available ;
- };
+ // printf("De-allocating %d\n", ( obj - data ) / N ) ;
+ stack[available >> HEAP_BASE][available & HEAP_MASK] = (UCHAR *)obj;
+ available++;
+ // printf("%d %d\n", allocated, header[ allocated ]) ;
+}
- int getAll( )
- {
- return HEAP_UNIT * datablocknum ;
- };
+/**
+ * Print information
+ */
+void printInfo( )
+{
+ printf("Bytes: %d Used: %d Allocated: %d Maxfree: %d\n", getBytes(), getAllocated(), getAll(), stacksize);
+}
- int getBytes( )
- {
- return N ;
- };
+/**
+ * Query methods
+ */
+int getAllocated( )
+{
+ return HEAP_UNIT * datablocknum - available;
};
+int getAll( )
+{
+ return HEAP_UNIT * datablocknum;
+};
+
+int getBytes( )
+{
+ return N;
+};
+};
+
#endif
Modified: trunk/blender/intern/dualcon/intern/ModelReader.h
===================================================================
--- trunk/blender/intern/dualcon/intern/ModelReader.h 2012-05-08 22:07:06 UTC (rev 46437)
+++ trunk/blender/intern/dualcon/intern/ModelReader.h 2012-05-08 22:11:05 UTC (rev 46438)
@@ -33,31 +33,32 @@
class ModelReader
{
public:
- /// Constructor
- ModelReader(){} ;
+/// Constructor
+ModelReader(){
+};
- /// Get next triangle
- virtual Triangle* getNextTriangle( ) = 0 ;
- virtual int getNextTriangle( int t[3] ) = 0 ;
+/// Get next triangle
+virtual Triangle *getNextTriangle( ) = 0;
+virtual int getNextTriangle(int t[3]) = 0;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list