Exemple #1
0
int main(int argc, const char** argv)
{
	//fprintf(stderr,"%s\n","Who even knows the even what?");
	
	FILE* f;
	const char* fname = 0;
	char* buf;
	
	if (argc > 1)
		fname = argv[1];
	f = fopen(fname,"r");
	
	int buflen = 120;
	iter* fiter = new_iter(f,0,buflen,'\n');
	
	buf = fiter->buf;
	
	int h = -1;
	char* s = 0;
	char c[1024];
	char n = 0;
	int i = 0;
	do {
		//fprintf(stderr,"n: %i, %i, %08x\n",n,fiter->bufcount,fiter->flags);
		s = iter_next(fiter);
		printf("%s\n",s);
		i++;
	} while (s && i < 15);
	
	free_iter(fiter);
	fclose(f);
	
	return 0;
}
/*! \todo Michael:  optimize_vertex_position is probably not implemented
  in an optimal way.  We used to use all of the vertices in
  the patch as 'adjacent' vertices.  Now we call get_adjacent_vertex_indices.
  We could use a VERTICES_ON_VERTEX type of patch or a global patch?
*/
void SmartLaplacianSmoother::optimize_vertex_positions(PatchData &pd, 
                                                MsqError &err)
{
    //default the laplacian smoother to 3 even for 2-d elements.
    //int dim = get_mesh_set()->space_dim();
  size_t dim = 3;
  MsqVertex* verts=pd.get_vertex_array(err);  MSQ_ERRRTN(err);
    //the objective function evaluator
  OFEvaluator& obj_func = get_objective_function_evaluator();
    //variables for the function values.
  double orig_val=0;
  double mod_val=0;
    //compute the original function value and check validity
  bool valid_flag = obj_func.evaluate(pd,orig_val,err);  MSQ_ERRRTN(err);
  // does the Laplacian smoothing
  MsqFreeVertexIndexIterator free_iter(pd, err);  MSQ_ERRRTN(err);
  free_iter.reset();
  free_iter.next();
    //m is the free vertex.
  size_t m=free_iter.value();
  vector<size_t> vert_indices;
  vert_indices.reserve(25);
    //get vertices adjacent to vertex m
  pd.get_adjacent_vertex_indices(m,vert_indices,err);  MSQ_ERRRTN(err);
    //move vertex m
    //save the original position of the free vertex
  Vector3D orig_position(verts[m]);
    //smooth the patch
  centroid_smooth_mesh(pd, vert_indices.size(), vert_indices,
                       m, dim, err); MSQ_ERRRTN(err);
    //snap vertex m to domain
  pd.snap_vertex_to_domain(m,err);  MSQ_ERRRTN(err);
    //if the original function val was invalid, then we allow the move
    //But, if it wasn valid, we need to decide.
  if(valid_flag){
      //compute the new value
    valid_flag = obj_func.evaluate(pd,mod_val,err);  MSQ_ERRRTN(err);
      //if the new value is worse the original OR if the new value is not
      //valid (we already know the original value was valid by above) then
      //we don't allow the move.
    if(!valid_flag || mod_val>orig_val){
        //move the vert back to where it was.
      verts[m]=orig_position;
        //PRINT_INFO("\norig = %f, new = %f, new valid = %d",orig_val,mod_val,valid_flag);
    }
    
  }
  
}
Exemple #3
0
void							  generate_position()
{
	// Allocates memory for new Iteration and Params_Template structures.
	Iterate* iter = generate_iter();
  iter->params->params = malloc(sizeof(Params_Position));
	// Initializes iter's fields.
	iter->compute_result = &compute_result_position;
	iter->free_params = &free_params_position;
  iter->scan = &scan_position;
  iter->params->result_type = POSITION_DEVICE;
  iter->params->result_model = OTHER;
	// Iterates.
	iterate_devices(iter);
	// Frees allocated ressources.
	free_iter(iter);
}
/*!
 */
  void I_DFT_NoBarrierSmoother::optimize_vertex_positions(PatchData &pd, 
                                                          MsqError &err)
  {
    MSQ_FUNCTION_TIMER( "I_DFT_NoBarrierSmoother::optimize_vertex_positions" );
    
      // does the I_DFT_NoBarrier smoothing
    MsqFreeVertexIndexIterator free_iter(pd, err);  MSQ_ERRRTN(err);
    free_iter.reset();
    free_iter.next();
      //m is the free vertex.
    size_t m=free_iter.value();
      //move vertex m
    i_dft_no_barrier_smooth_mesh(pd, m, err); MSQ_ERRRTN(err);
      //snap vertex m to domain
    pd.snap_vertex_to_domain(m,err);
  
  }
Exemple #5
0
void							generate_vgyro()
{
	// Allocates memory for new Iteration and Params_Vaccel structures.
	Iterate *iter = generate_iter();
  Params_Vgyro *params_ = malloc(sizeof(Params_Vgyro));
  // Create a kalman filter using the data configuration for it.
  Conf *c = load_config_data();
  params_->kf = build_kalman(c);
  free_conf(c);
	// Initializes iter's fields.
	iter->compute_result = &compute_result_vgyro;
	iter->initialize_per_axis = &initialize_per_axis_vgyro;
	iter->free_params = &free_params_vgyro;
  iter->scan = &scan_vgyro;
  iter->params->params = params_;
  iter->params->result_type = GYROSCOPE;
  iter->params->result_model = VIRTUAL;
	// Iterates.
	iterate_devices(iter);
	// Frees allocated ressources.
	free_iter(iter);
}