コード例 #1
0
ファイル: R_DimSqueezer.cpp プロジェクト: lmjakt/R-SOD
Rcpp::List prepare_return_data(MappingInfo& mapInfo)
{
  NumericMatrix m_positions(mapInfo.node_no, mapInfo.dim_no);
  
  for(unsigned int i=0; i < mapInfo.node_no; ++i){
    for(unsigned int j=0; j < mapInfo.dim_no; ++j){
      m_positions(i,j) = mapInfo.mapped_points[ i * mapInfo.dim_no + j ]; // This works !?
    }
  }

  NumericMatrix mappingDims(mapInfo.stress.size(), mapInfo.dim_no);
  std::vector<float> globalStress(mapInfo.stress.size());
  for(unsigned int i=0; i < mapInfo.stress.size(); ++i){
    globalStress[i] = mapInfo.stress[i].stress;
    for(unsigned int j=0; j < mapInfo.dim_no; ++j)
      mappingDims(i, j) = mapInfo.stress[i].dimFactors[j];
  }
  
  return(Rcpp::List::create(Rcpp::Named("stress", globalStress),
			    Rcpp::Named("mapDims", mappingDims),
			    Rcpp::Named("pos", m_positions),
			    Rcpp::Named("time", mapInfo.timeData),
			    Rcpp::Named("node_stress", mapInfo.node_stress))	 
	 );
  
}
コード例 #2
0
ファイル: Balloon.cpp プロジェクト: nawafuji/PBSproject
void Balloon::checkfloor()
{
    double limit = -0.5;
    for (int i = 0; i<m_positions.rows(); i++) {
      if(m_positions(i,2) <= limit){
        m_positions(i,2) = limit;
        m_speeds.row(i) = m_speeds.row(i)/10.0;
      }
    }
}
コード例 #3
0
ファイル: Balloon.cpp プロジェクト: nawafuji/PBSproject
void Balloon::render()
{
    glColor3f(0.5,0.5,0.5);
    for(int i=0; i<m_positions.rows(); i++)
    {
      glPushMatrix();
      {
        glTranslated(m_positions(i,0), m_positions(i,1), m_positions(i,2));
        glutSolidSphere(1.0, 50, 50);
      }
      glPopMatrix();

      glPushMatrix();
      {
        if(renderNormals)
        {
          double nl = 10;
          glLineWidth(0.05);
          glColor3f(0.0, 1.0, 0.0);
          glBegin(GL_LINES);
          glVertex3d(m_positions(i,0), m_positions(i,1), m_positions(i,2));
          glVertex3d(m_positions(i,0) + m_normals(i,0) * nl, m_positions(i,1) + m_normals(i,1) * nl, m_positions(i,2) + m_normals(i,2) * nl);
          glEnd();
        }
      }
      glPopMatrix();
    }

    for(int i=0; i<m_faces.rows(); i++)
    {
      glPushMatrix();
      {
        if(m_faceactive(i) == 1)
        {
          glLineWidth(0.1);
          glColor3f(0.0, 1.0, 0.0);
          glBegin(GL_TRIANGLES);
          glVertex3d(m_positions(m_faces(i,0),0), m_positions(m_faces(i,0),1), m_positions(m_faces(i,0),2));
          glVertex3d(m_positions(m_faces(i,1),0), m_positions(m_faces(i,1),1), m_positions(m_faces(i,1),2));
          glVertex3d(m_positions(m_faces(i,2),0), m_positions(m_faces(i,2),1), m_positions(m_faces(i,2),2));
          glEnd();
        }
      }
      glPopMatrix();
    }
}