1 // Copyright (c) 2013-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Prs3d_Point_H__
15 #define _Prs3d_Point_H__
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>
24 template <class AnyPoint, class PointTool>
25 class Prs3d_Point : Prs3d_Root
31 Standard_EXPORT static void DrawPoint
32 (const AnyPoint& thePoint,
33 const Handle(Graphic3d_Group) theGroup)
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);
43 Standard_EXPORT static void Add
44 (const Handle (Prs3d_Presentation)& thePresentation,
45 const AnyPoint& thePoint,
46 const Handle (Prs3d_Drawer)& theDrawer)
48 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
49 aGroup->SetPrimitivesAspect(theDrawer->PointAspect()->Aspect());
50 DrawPoint(thePoint, aGroup);
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)
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;