0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / Prs3d / Prs3d_Point.hxx
1 // Copyright (c) 2013-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _Prs3d_Point_H__
15 #define _Prs3d_Point_H__
16
17 #include <Graphic3d_ArrayOfPoints.hxx>
18 #include <Graphic3d_Vertex.hxx>
19 #include <Graphic3d_Group.hxx>
20 #include <Prs3d_Drawer.hxx>
21 #include <Prs3d_PointAspect.hxx>
22 #include <Prs3d_Root.hxx>
23
24 template <class AnyPoint, class PointTool>
25 class Prs3d_Point : Prs3d_Root
26 {
27 public:
28   DEFINE_STANDARD_ALLOC
29
30 private:
31   Standard_EXPORT static void DrawPoint
32                  (const AnyPoint& thePoint,
33                   const Handle(Graphic3d_Group) theGroup)
34   {
35     Standard_Real aX,aY,aZ;
36     PointTool::Coord(thePoint,aX,aY,aZ);
37     Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
38     anArrayOfPoints->AddVertex (aX, aY, aZ);
39     theGroup->AddPrimitiveArray (anArrayOfPoints);
40   }
41
42 public:
43   Standard_EXPORT static void Add
44                  (const Handle (Prs3d_Presentation)& thePresentation,
45                   const AnyPoint& thePoint,
46                   const Handle (Prs3d_Drawer)& theDrawer)
47   {
48     Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
49     aGroup->SetPrimitivesAspect(theDrawer->PointAspect()->Aspect());
50     DrawPoint(thePoint, aGroup);
51   }
52
53   Standard_EXPORT static Standard_Boolean Match
54                   (const AnyPoint& thePoint,
55                   const Standard_Real theX,
56                   const Standard_Real theY,
57                   const Standard_Real theZ,
58                   const Standard_Real theDistance)
59   {
60     Standard_Real aX,aY,aZ;
61     PointTool::Coord(thePoint, aX, aY, aZ);
62     return Sqrt((theX - aX)*(theX - aX) + (theY - aY)*(theY - aY)
63                  + (theZ - aZ)*(theZ - aZ)) <= theDistance;
64   }
65 };
66
67 #endif