0024428: Implementation of LGPL license
[occt.git] / src / Prs3d / Prs3d_Point.hxx
1 // Copyright (c) 2013 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
6 // under the terms of the GNU Lesser General Public 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
18 #include <Graphic3d_ArrayOfPoints.hxx>
19 #include <Graphic3d_Vertex.hxx>
20 #include <Graphic3d_Group.hxx>
21 #include <Prs3d_Drawer.hxx>
22 #include <Prs3d_PointAspect.hxx>
23 #include <Prs3d_Root.hxx>
24 #include <Quantity_Length.hxx>
25
26 template <class AnyPoint, class PointTool>
27 class Prs3d_Point : Prs3d_Root
28 {
29 public:
30   DEFINE_STANDARD_ALLOC
31
32 private:
33   Standard_EXPORT static void DrawPoint
34                  (const AnyPoint& thePoint,
35                   const Handle(Graphic3d_Group) theGroup)
36   {
37     Quantity_Length aX,aY,aZ;
38     PointTool::Coord(thePoint,aX,aY,aZ);
39     Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
40     anArrayOfPoints->AddVertex (aX, aY, aZ);
41     theGroup->AddPrimitiveArray (anArrayOfPoints);
42   }
43
44 public:
45   Standard_EXPORT static void Add
46                  (const Handle (Prs3d_Presentation)& thePresentation,
47                   const AnyPoint& thePoint,
48                   const Handle (Prs3d_Drawer)& theDrawer)
49   {
50     Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
51     aGroup->SetPrimitivesAspect(theDrawer->PointAspect()->Aspect());
52     DrawPoint(thePoint, aGroup);
53   }
54
55   Standard_EXPORT static Standard_Boolean Match
56                   (const AnyPoint& thePoint,
57                   const Quantity_Length theX,
58                   const Quantity_Length theY,
59                   const Quantity_Length theZ,
60                   const Quantity_Length theDistance)
61   {
62     Quantity_Length aX,aY,aZ;
63     PointTool::Coord(thePoint, aX, aY, aZ);
64     return Sqrt((theX - aX)*(theX - aX) + (theY - aY)*(theY - aY)
65                  + (theZ - aZ)*(theZ - aZ)) <= theDistance;
66   }
67 };
68 #endif