当前位置: 首页>>代码示例>>C++>>正文


C++ Primitive::mainDiagonal方法代码示例

本文整理汇总了C++中Primitive::mainDiagonal方法的典型用法代码示例。如果您正苦于以下问题:C++ Primitive::mainDiagonal方法的具体用法?C++ Primitive::mainDiagonal怎么用?C++ Primitive::mainDiagonal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Primitive的用法示例。


在下文中一共展示了Primitive::mainDiagonal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int argc, char** argv )
{
  using namespace Z3i;

  QApplication application(argc,argv);
  trace.beginBlock ( "Testing class ChordNaivePlaneComputer" );

  unsigned int nbok = 0;
  unsigned int nb = 0;
  typedef ChordNaivePlaneComputer<Z3, Z3::Point, int> PlaneComputer;
  typedef PlaneComputer::Primitive Primitive;

  PlaneComputer plane;
  plane.init( 2, 1, 1 );
  Point pt0( 0, 0, 0 );
  bool pt0_inside = plane.extend( pt0 );
  trace.info() << "(" << nbok << "/" << nb << ") Plane=" << plane
               << std::endl;
  Point pt1( 8, 1, 3 );
  bool pt1_inside = plane.extend( pt1 );
  ++nb, nbok += pt1_inside == true ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") add " << pt1
               << " Plane=" << plane << std::endl;
  Point pt2( 2, 7, 1 );
  bool pt2_inside = plane.extend( pt2 );
  ++nb, nbok += pt2_inside == true ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") add " << pt2
               << " Plane=" << plane << std::endl;

  Point pt3( 0, 5, 12 );
  bool pt3_inside = plane.extend( pt3 );
  ++nb, nbok += pt3_inside == false ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") add " << pt3
               << " Plane=" << plane << std::endl;

  Point pt4( -5, -5, 10 );
  bool pt4_inside = plane.extend( pt4 );
  ++nb, nbok += pt4_inside == false ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") add " << pt4
               << " Plane=" << plane << std::endl;

  Point pt5 = pt0 + pt1 + pt2 + Point( 0, 0, 1 );
  bool pt5_inside = plane.extend( pt5 );
  ++nb, nbok += pt5_inside == true ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") add " << pt5
               << " Plane=" << plane << std::endl;

  Point pt6 = Point( 1, 0, 1 );
  bool pt6_inside = plane.extend( pt6 );
  ++nb, nbok += pt6_inside == true ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") add " << pt5
               << " Plane=" << plane << std::endl;

  Primitive strip = plane.primitive();
  trace.info() << "strip=" << strip
               << " axis=" << strip.mainAxis()
               << " axiswidth=" << strip.axisWidth()
               << " diag=" << strip.mainDiagonal()
               << " diagwidth=" << strip.diagonalWidth()
               << std::endl;
  ++nb, nbok += strip.axisWidth() < 1.0 ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") axiswidth < 1 "
               << std::endl;
  ++nb, nbok += strip.diagonalWidth() < sqrt(3.0) ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb << ") axiswidth < sqrt(3) "
               << std::endl;

  trace.emphase() << ( nbok == nb ? "Passed." : "Error." ) << endl;
  trace.endBlock();

  typedef Viewer3D<> MyViewer;
  MyViewer viewer;
  viewer.show();
  Color red( 255, 0, 0 );
  Color green( 0, 255, 0 );
  Color grey( 200, 200, 200 );
  Domain domain( Point( -5, -5, -5 ), Point( 12, 12, 12 ) );
  viewer << ( pt0_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt0;
  viewer << ( pt1_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt1;
  viewer << ( pt2_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt2;
  viewer << ( pt3_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt3;
  viewer << ( pt4_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt4;
  viewer << ( pt5_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt5;
  viewer << ( pt6_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt6;
  viewer << CustomColors3D( grey, grey );
  displayPredicate( viewer, domain, plane );

  viewer << MyViewer::updateDisplay;


  return application.exec();
}
开发者ID:151706061,项目名称:DGtal,代码行数:92,代码来源:viewer3D-7bis-planes.cpp

示例2: main

int main( int argc, char** argv )
{
  using namespace Z3i;
  unsigned int nb = 0;
  unsigned int nbok = 0;

  QApplication application(argc,argv);

  unsigned int diameter = argc > 1 ? atoi( argv[ 1 ] ) : 10;
  int a = argc > 2 ? atoi( argv[ 2 ] ) : 2;
  int b = argc > 3 ? atoi( argv[ 3 ] ) : 3;
  int c = argc > 4 ? atoi( argv[ 4 ] ) : 5;
  int mu = argc > 5 ? atoi( argv[ 5 ] ) : 0;
  trace.beginBlock ( "Testing class ChordGenericStandardPlaneComputer" );
  trace.info() << "Recognizing plane "
               << mu << " <= " << a << " * x + "
               << b << " * y + " << c << " * z < " 
               << (mu+abs(a)+abs(b)+abs(c)) << std::endl;
  Domain domain1( Point( -diameter, -diameter, -diameter ),
                  Point(  diameter,  diameter,  diameter ) );
  
  typedef int64_t Integer;
  typedef ChordGenericStandardPlaneComputer<Z3, Point, Integer> PlaneComputer;
  typedef PlaneComputer::Primitive Primitive;
  PlaneComputer plane;
  plane.init( 1, 1 );
  
  std::vector<Point> recognized = pointsInStandardPlane( domain1, 
                                                         a, b , c, mu );
  ++nb, nbok += plane.extend( recognized.begin(), recognized.end() ) ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb
               << ") All points are recognized." << std::endl;
  trace.info() << " - Plane=" << plane
               << std::endl;
  Primitive strip = plane.primitive();
  trace.info() << "strip=" << strip 
               << " axis=" << strip.mainAxis()
               << " axiswidth=" << strip.axisWidth()
               << " diag=" << strip.mainDiagonal()
               << " diagwidth=" << strip.diagonalWidth()
               << std::endl;
  ++nb, nbok += ( strip.diagonalWidth() < sqrt(3.0) ) ? 1 : 0;
  trace.info() << "(" << nbok << "/" << nb
               << ") Diagonal width < sqrt(3)." << std::endl;
  trace.emphase() << ( (nb == nbok) ? "Passed." : "Error." ) << endl;
  trace.endBlock();

  typedef Viewer3D<> MyViewer;
  MyViewer viewer;
  viewer.show();
  Color red( 255, 0, 0 );
  Color green( 0, 255, 0 );
  Color grey( 200, 200, 200 );
  Domain domain2( Point( -2*diameter, -2*diameter, -2*diameter ),
                  Point(  2*diameter,  2*diameter,  2*diameter ) );
  viewer << CustomColors3D( red, red );
  for ( std::vector<Point>::const_iterator it = recognized.begin(),
          itE = recognized.end(); it != itE; ++it )
    if ( ! strip( *it ) ) viewer << *it;
  viewer << CustomColors3D( green, green );
  displayRange( viewer, plane.begin(), plane.end() );
  viewer << CustomColors3D( grey, grey );
  displayPredicate( viewer, domain2, strip );
  viewer << MyViewer::updateDisplay;
  trace.info() << "- Points in green have been recognized as belonging to this standard plane." << std::endl;
  trace.info() << "- Points in grey belongs also to the parallel strip of the recognized standard plane." << std::endl;
  trace.info() << "- Points in red belongs to the parallel strip of the recognized standard plane but not to the input standard plane: NONE should be red." << std::endl;

  return application.exec();
}
开发者ID:arnaudetitia,项目名称:DGtal,代码行数:70,代码来源:viewer3D-7bis-stdplane.cpp


注:本文中的Primitive::mainDiagonal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。