void SurfacePlot::createNormalsC()
{
	if (!normals() || actualData_p->empty())
		return;

	if (actualDataC_->nodes.size() != actualDataC_->normals.size())
		return;
  Arrow arrow;
  arrow.setQuality(normalQuality());

	Triple basev, topv, norm;	
		
	double diag = (actualData_p->hull().maxVertex-actualData_p->hull().minVertex).length() * normalLength();

  RGBA col;
  arrow.assign(*this);
  arrow.drawBegin();
	for (unsigned i = 0; i != actualDataC_->normals.size(); ++i) 
	{
		basev = actualDataC_->nodes[i];
		topv = basev + actualDataC_->normals[i];
		
			norm = topv-basev;
			norm.normalize();
			norm	*= diag;

      arrow.setTop(basev+norm);
      arrow.setColor((*datacolor_p)(basev.x,basev.y,basev.z));
      arrow.draw(basev);
	}
  arrow.drawEnd();
}
示例#2
0
void Curve::createNormalsG()
{
	if (!normals() || actualDataG_->empty())
		return;

	Arrow arrow;
	arrow.setQuality(normalQuality());

	Triple basev, topv, norm;	
	
	int step = resolution();

	double diag = (actualDataG_->hull().maxVertex-actualDataG_->hull().minVertex).length() * normalLength();

	arrow.assign(*this);
	arrow.drawBegin();
	for (int i = 0; i <= actualDataG_->columns() - step; i += step){
		for (int j = 0; j <= actualDataG_->rows() - step; j += step){
			basev = Triple(actualDataG_->vertices[i][j][0],actualDataG_->vertices[i][j][1],actualDataG_->vertices[i][j][2]);
			topv = Triple(actualDataG_->vertices[i][j][0]+actualDataG_->normals[i][j][0],
							 actualDataG_->vertices[i][j][1]+actualDataG_->normals[i][j][1],
							 actualDataG_->vertices[i][j][2]+actualDataG_->normals[i][j][2]);	
			
			norm = topv-basev;
			norm.normalize();
			norm	*= diag;

			arrow.setTop(basev+norm);
			arrow.setColor((*datacolor_p)(basev.x,basev.y,basev.z));
			arrow.draw(basev);
		}
	}
	arrow.drawEnd();
}
示例#3
0
void GridPlot::createNormals(const Plotlet& pl)
{
    if (!normals())
        return;

    Arrow arrow;
    arrow.setQuality(normalQuality());

    Triple /*basev, topv, */ norm;

    int step = resolution();

    const GridData& data = dynamic_cast<const GridData&>(*pl.data);
    const Color& color = *pl.appearance->dataColor();
    double diag = (data.hull().maxVertex-data.hull().minVertex).length() * normalLength();

    arrow.assign(*this);
    arrow.drawBegin();
    for (int i = 0; i <= data.columns() - step; i += step)
    {
        for (int j = 0; j <= data.rows() - step; j += step)
        {
            norm = data.normals[i][j];//topv-basev;
            norm.normalize();
            norm	*= diag;

            const Triple &vert = data.vertices[i][j];
            arrow.setTop(vert+norm);
            arrow.setColor(color.rgba(vert.x, vert.y, vert.z));
            arrow.draw(vert);
        }
    }
    arrow.drawEnd();
}