本文整理汇总了C++中SWIFT_Array::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ SWIFT_Array::Create方法的具体用法?C++ SWIFT_Array::Create怎么用?C++ SWIFT_Array::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SWIFT_Array
的用法示例。
在下文中一共展示了SWIFT_Array::Create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create_One_Piece
void Create_One_Piece( SWIFT_Tri_Mesh* m, SWIFT_Array<int>& piece_ids,
SWIFT_Array< SWIFT_Array<int> >& mfs,
SWIFT_Array< SWIFT_Array<SWIFT_Tri_Face> >& vfs )
{
int i;
piece_ids.Create( m->Num_Faces() );
mfs.Create( 1 );
mfs[0].Create( m->Num_Faces() );
for( i = 0; i < m->Num_Faces(); i++ ) {
mfs[0][i] = i;
piece_ids[i] = 0;
}
vfs.Create( 1 );
}
示例2: Convex_Initialize
void Convex_Initialize( SWIFT_Tri_Mesh* m )
{
int i;
Convex_Utilities_Initialize( m );
// Store the mesh's twin info in the twin's list
twins.Create( m->Num_Faces() );
for( i = 0; i < m->Num_Faces(); i++ ) {
twins[i][0] = m->Faces()[i].Edge1().Twin();
twins[i][1] = m->Faces()[i].Edge2().Twin();
twins[i][2] = m->Faces()[i].Edge3().Twin();
}
}
示例3: Compute_Leaves
void Compute_Leaves( SWIFT_BV* piece )
{
int i;
if( piece == mesh->Root() ) {
leaves.Destroy();
leaves.Create( num_leaves );
leaves.Set_Length( 0 );
}
if( piece->Is_Leaf() ) {
leaves.Add( piece );
} else {
for( i = 0; i < piece->Num_Children(); i++ ) {
Compute_Leaves( piece->Children()[i] );
}
}
}
示例4: Compute_Piece_Centers_Of_Mass
void Compute_Piece_Centers_Of_Mass( )
{
int i, j;
SWIFT_Real area;
SWIFT_Real total_area;
SWIFT_Triple areav;
SWIFT_Triple com;
if( model_faces.Length() != 0 ) {
piece_coms.Create( model_faces.Length() );
for( i = 0; i < model_faces.Length(); i++ ) {
com.Set_Value( 0.0, 0.0, 0.0 );
total_area = 0.0;
for( j = 0; j < model_faces[i].Length(); j++ ) {
areav = (mesh->Faces()[model_faces[i][j]].Edge1().Origin()->Coords() -
mesh->Faces()[model_faces[i][j]].Edge2().Origin()->Coords()) %
(mesh->Faces()[model_faces[i][j]].Edge1().Origin()->Coords() -
mesh->Faces()[model_faces[i][j]].Edge3().Origin()->Coords());
area = 0.5 * areav.Length();
total_area += area;
com += area * (mesh->Faces()[model_faces[i][j]].Edge1().Origin()->Coords() +
mesh->Faces()[model_faces[i][j]].Edge2().Origin()->Coords() +
mesh->Faces()[model_faces[i][j]].Edge3().Origin()->Coords() );
}
for( j = 0; j < virtual_faces[i].Length(); j++ ) {
areav = (virtual_faces[i][j].Edge1().Origin()->Coords() -
virtual_faces[i][j].Edge2().Origin()->Coords()) %
(virtual_faces[i][j].Edge1().Origin()->Coords() -
virtual_faces[i][j].Edge3().Origin()->Coords());
area = 0.5 * areav.Length();
total_area += area;
com += area * (virtual_faces[i][j].Edge1().Origin()->Coords() +
virtual_faces[i][j].Edge2().Origin()->Coords() +
virtual_faces[i][j].Edge3().Origin()->Coords() );
}
piece_coms[i] = com / (3.0 * total_area);
}
}
}
示例5: Gui_Init_Before_TclTk
void Gui_Init_Before_TclTk( char* filename )
{
#ifdef DECOMP_GRAPHICS
if( g ) {
// toggle and radio button variables
backface = 1;
wireframe = 0;
color = 1;
axes = 1;
explode = 0;
prevdh = DRAW_DECOMPOSITION;
dh = DRAW_DECOMPOSITION;
edge_conv = 0;
vfaces = 0;
save_vfaces = 1; // turn vfaces on by default for the hierarchy
tcolor = 0;
uleaves = 0;
level = 0;
// Mode variables
dragging = false;
VIEWER_Initialize();
}
#endif
mesh = NULL;
Mesh_Utils_Initialize();
if( filename != NULL ) {
int i, j, k;
if( !Load_File( filename, mesh, split, already_decomp, already_hier,
piece_ids, model_faces, virtual_faces )
) {
cerr << "Exiting..." << endl;
exit( 0 );
return;
}
if( already_hier ) {
// Have to compute the mesh geometry
mesh->Compute_All_Hierarchy_Geometry();
}
mesh->Compute_Edge_Convexities( edge_convexities );
if( !already_decomp ) {
if( jitter ) {
cerr << "Jittering with amplitude = " << jampl << endl << endl;
Jitter( mesh, jampl );
}
if( ef ) {
// Flip edges
cerr << "Flipping edges with tolerance = " << edge_flip_tol
<< endl << endl;
Edge_Flip( mesh, edge_flip_tol );
if( ef_filename != NULL ) {
cerr << "Saving edge flipped mesh" << endl << endl;
Save_Model_File( ef_filename, mesh );
}
}
if( one_piece ) {
cerr << "Creating one piece" << endl;
Create_One_Piece( mesh, piece_ids, model_faces, virtual_faces );
num_pieces = 1;
} else {
Decompose_Mesh( );
}
// Write the result to a file if that option is on
if( w ) {
cerr << "Saving decomposition result" << endl << endl;
Save_Decomposition_File( decomp_filename, mesh, piece_ids,
model_faces, virtual_faces );
}
} else if( !already_hier ) {
num_pieces = model_faces.Length();
} else {
num_pieces = (mesh->Num_BVs()+1)/2;
}
if( hierarchy ) {
// Create the bounding volume hierarchy
num_leaves = num_pieces;
if( !already_hier ) {
cerr << "Creating convex hierarchy" << endl;
mesh->Create_BV_Hierarchy( split, piece_ids, model_faces,
virtual_faces, st_faces, st_twins );
if( hier_filename != NULL ) {
cerr << "Saving convex hierarchy" << endl << endl;
Save_Hierarchy_File( hier_filename, mesh,
st_faces, st_twins );
}
}
#ifdef DECOMP_GRAPHICS
} else {
//.........这里部分代码省略.........
示例6: Decompose_DFS
int Decompose_DFS( SWIFT_Tri_Mesh* m, SWIFT_Array<int>& piece_ids,
SWIFT_Array< SWIFT_Array<int> >& mfs,
SWIFT_Array< SWIFT_Array<SWIFT_Tri_Face> >& vfs,
bool random )
{
// Start performing DFS on the dual graph maintaining a convex hull along
// the way.
cerr << endl << "Starting ";
if( random ) {
cerr << "randomized ";
}
cerr << "DFS decomposition" << endl;
const unsigned int max_faces_in_a_chull = (m->Num_Vertices() - 2) << 1;
int i, j, k, l, p;
int created_faces = 0;
int top, id;
// The faces stack
SWIFT_Array<SWIFT_Tri_Face*> sfs;
// Keeps track of all the faces that were marked as failed so that they can
// be unmarked efficiently.
SWIFT_Array<SWIFT_Tri_Face*> mark_failed;
// The current convex hull
SWIFT_Array<SWIFT_Tri_Face> chull;
// Pointers to faces indicating whether the face on the convex hull is a
// model face or a virtual face (entry is NULL)
SWIFT_Array<SWIFT_Tri_Face*> cfs;
// Which faces on the original model are allowed to be added
SWIFT_Array<bool> fallowed;
// Which vertices exist on the convex hull
SWIFT_Array<bool> cvs;
// Ids of vertices belonging to the convex hull
SWIFT_Array<int> cvs_idx;
// Ids of faces that are added at each iteration
SWIFT_Array<int> addedfs;
// The model face ids that belong to a single convex hull
SWIFT_Array<int> temp_mfs_1d;
// The model face ids that belong to each convex hull
SWIFT_Array< SWIFT_Array<int> > temp_mfs_2d;
sfs.Create( m->Num_Faces() );
mark_failed.Create( m->Num_Faces() );
chull.Create( max_faces_in_a_chull );
cfs.Create( max_faces_in_a_chull );
fallowed.Create( m->Num_Faces() );
cvs.Create( m->Num_Vertices() );
cvs_idx.Create( m->Num_Vertices() );
addedfs.Create( m->Num_Faces() );
temp_mfs_1d.Create( m->Num_Faces() );
temp_mfs_2d.Create( m->Num_Faces() );
vfs.Create( m->Num_Faces() );
piece_ids.Create( m->Num_Faces() );
Prepare_Mesh_For_Decomposition( m );
for( i = 0; i < m->Num_Faces(); i++ ) {
fallowed[i] = true;
}
for( i = 0; i < m->Num_Vertices(); i++ ) {
cvs[i] = false;
}
cvs_idx.Set_Length( 0 );
id = 0;
for( p = 0; p < m->Num_Faces(); ) {
// Try to advance p
for( ; p < m->Num_Faces() && m->Faces()[p].Marked(); p++ );
if( p == m->Num_Faces() ) break;
if( random ) {
// Find a random i in the range [p,m->Num_Faces()-1]
while( m->Faces()[i = (int) ((SWIFT_Real)(m->Num_Faces()-p) *
drand48()) + p].Marked() );
} else {
i = p;
}
top = 0;
sfs[0] = m->Faces()(i);
mark_failed.Set_Length( 0 );
temp_mfs_1d.Set_Length( 0 );
Create_First_Face( m->Faces()(i), chull, cfs );
// Unset all the vertex membership flags
for( j = 0; j < cvs_idx.Length(); j++ ) {
cvs[cvs_idx[j]] = false;
}
cvs_idx.Set_Length( 0 );
// Mark the first three vertices as added to the hull
cvs_idx.Add( m->Vertex_Id( m->Faces()[i].Edge1().Origin() ) );
cvs_idx.Add( m->Vertex_Id( m->Faces()[i].Edge2().Origin() ) );
cvs_idx.Add( m->Vertex_Id( m->Faces()[i].Edge3().Origin() ) );
cvs[cvs_idx[0]] = true;
cvs[cvs_idx[1]] = true;
cvs[cvs_idx[2]] = true;
// Add the first face
//.........这里部分代码省略.........
示例7: Decompose_Cresting_BFS
int Decompose_Cresting_BFS( SWIFT_Tri_Mesh* m, SWIFT_Array<int>& piece_ids,
SWIFT_Array< SWIFT_Array<int> >& mfs,
SWIFT_Array< SWIFT_Array<SWIFT_Tri_Face> >& vfs )
{
// Start performing BFS on the dual graph maintaining a convex hull along
// the way.
cerr << endl << "Starting cresting BFS decomposition" << endl;
const unsigned int max_faces_in_a_chull = (m->Num_Vertices() - 2) << 1;
int i, j, k, l;
int created_faces = 0;
int front, id;
bool add_children;
SWIFT_Tri_Edge* e;
SWIFT_Tri_Vertex* v;
SWIFT_Array<SWIFT_Tri_Face*> qfs; // The queue
SWIFT_Array<SWIFT_Tri_Face*> qfs_parents;
SWIFT_Array<int> qmap;
SWIFT_Array<int> qmap_idx;
SWIFT_Array<SWIFT_Tri_Face*> mark_failed;
SWIFT_Array<SWIFT_Tri_Face> chull;
SWIFT_Array<SWIFT_Tri_Face*> cfs;
SWIFT_Array<bool> fallowed;
SWIFT_Array<bool> cvs;
SWIFT_Array<int> cvs_idx;
SWIFT_Array<int> addedfs;
SWIFT_Array<int> temp_mfs_1d;
SWIFT_Array< SWIFT_Array<int> > temp_mfs_2d;
// The priority queue
SWIFT_Array<int> lengths( m->Num_Faces() );
SWIFT_Array<int> bmap( m->Num_Faces() );
SWIFT_Array<int> fmap( m->Num_Faces() );
qfs.Create( m->Num_Faces() );
qfs_parents.Create( m->Num_Faces() );
qmap.Create( m->Num_Faces() );
qmap_idx.Create( m->Num_Faces() );
mark_failed.Create( m->Num_Faces() );
chull.Create( max_faces_in_a_chull );
cfs.Create( max_faces_in_a_chull );
fallowed.Create( m->Num_Faces() );
cvs.Create( m->Num_Vertices() );
cvs_idx.Create( m->Num_Vertices() );
addedfs.Create( m->Num_Faces() );
temp_mfs_1d.Create( m->Num_Faces() );
temp_mfs_2d.Create( m->Num_Faces() );
vfs.Create( m->Num_Faces() );
piece_ids.Create( m->Num_Faces() );
Prepare_Mesh_For_Decomposition( m );
cvs_idx.Set_Length( 0 );
qmap_idx.Set_Length( 0 );
for( i = 0; i < m->Num_Vertices(); i++ ) {
cvs[i] = false;
}
for( i = 0; i < m->Num_Faces(); i++ ) {
fallowed[i] = true;
piece_ids[i] = -1;
qmap[i] = -1;
bmap[i] = fmap[i] = i;
if( m->Faces()[i].Edge1().Unmarked() ||
m->Faces()[i].Edge2().Unmarked() ||
m->Faces()[i].Edge3().Unmarked()
) {
lengths[i] = 0;
qmap_idx.Add( i );
} else {
lengths[i] = -1;
}
}
id = 0;
// Calculate distances for each face and create priority queue
if( !qmap_idx.Empty() ) {
// This is a convex object
for( i = 0; i < qmap_idx.Max_Length(); i++ ) {
if( m->Faces()[qmap_idx[i]].Edge1().Twin() != NULL ) {
k = m->Face_Id(
m->Faces()[qmap_idx[i]].Edge1().Twin()->Adj_Face() );
if( lengths[k] == -1 ) {
lengths[k] = lengths[qmap_idx[i]]+1;
qmap_idx.Add( k );
}
}
if( m->Faces()[qmap_idx[i]].Edge2().Twin() != NULL ) {
k = m->Face_Id(
m->Faces()[qmap_idx[i]].Edge2().Twin()->Adj_Face() );
if( lengths[k] == -1 ) {
lengths[k] = lengths[qmap_idx[i]]+1;
qmap_idx.Add( k );
}
}
if( m->Faces()[qmap_idx[i]].Edge3().Twin() != NULL ) {
k = m->Face_Id(
m->Faces()[qmap_idx[i]].Edge3().Twin()->Adj_Face() );
//.........这里部分代码省略.........