forked from mcneel/opennurbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopennurbs_pointgeometry.cpp
156 lines (129 loc) · 3.29 KB
/
opennurbs_pointgeometry.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
#include "opennurbs.h"
#if !defined(ON_COMPILING_OPENNURBS)
// This check is included in all opennurbs source .c and .cpp files to insure
// ON_COMPILING_OPENNURBS is defined when opennurbs source is compiled.
// When opennurbs source is being compiled, ON_COMPILING_OPENNURBS is defined
// and the opennurbs .h files alter what is declared and how it is declared.
#error ON_COMPILING_OPENNURBS must be defined when compiling opennurbs
#endif
ON_OBJECT_IMPLEMENT( ON_Point, ON_Geometry, "C3101A1D-F157-11d3-BFE7-0010830122F0" );
bool ON_Point::IsValid( ON_TextLog* text_log ) const
{
bool rc = point.IsValid();
if ( !rc && text_log )
{
text_log->Print("ON_Point::point is not a valid 3d point.\n");
}
return rc;
}
void ON_Point::Dump( ON_TextLog& dump ) const
{
dump.Print("ON_Point: ");
dump.Print(point);
dump.Print("\n");
}
bool ON_Point::Write( ON_BinaryArchive& file ) const
{
bool rc = file.Write3dmChunkVersion(1,0);
if (rc) rc = file.WritePoint( point );
return rc;
}
bool ON_Point::Read( ON_BinaryArchive& file )
{
int major_version = 0;
int minor_version = 0;
bool rc = file.Read3dmChunkVersion(&major_version,&minor_version);
if (rc && major_version==1) {
// common to all 1.x versions
rc = file.ReadPoint(point);
}
return rc;
}
ON::object_type ON_Point::ObjectType() const
{
return ON::point_object;
}
int ON_Point::Dimension() const
{
return 3;
}
bool ON_Point::GetBBox( double* boxmin, double* boxmax, bool bGrowBox ) const
{
return ON_GetPointListBoundingBox( 3, 0, 1, 3, &point.x, boxmin, boxmax, bGrowBox?true:false );
}
bool ON_Point::IsDeformable() const
{
return true;
}
bool ON_Point::MakeDeformable()
{
return true;
}
bool ON_Point::Transform( const ON_Xform& xform )
{
TransformUserData(xform);
return ON_TransformPointList(3,0,1,3,&point.x,xform);
}
bool ON_Point::SwapCoordinates( int i, int j )
{
return ON_SwapPointListCoordinates( 1, 3, &point.x, i, j );
}
ON_Point::ON_Point() : point(0.0,0.0,0.0)
{}
ON_Point::ON_Point(const ON_Point& src) : ON_Geometry(src), point(src.point)
{}
ON_Point::ON_Point(const ON_3dPoint& pt) : point(pt)
{}
ON_Point::ON_Point(double x,double y,double z) : point(x,y,z)
{}
ON_Point::~ON_Point()
{}
ON_Point& ON_Point::operator=(const ON_Point& src)
{
if ( this != &src ) {
ON_Geometry::operator=(src);
point=src.point;
}
return *this;
}
ON_Point& ON_Point::operator=(const ON_3dPoint& pt)
{
point=pt;
return *this;
}
ON_Point::operator double*()
{
return &point.x;
}
ON_Point::operator const double*() const
{
return &point.x;
}
ON_Point::operator ON_3dPoint*()
{
return &point;
}
ON_Point::operator const ON_3dPoint*() const
{
return &point;
}
ON_Point::operator ON_3dPoint&()
{
return point;
}
ON_Point::operator const ON_3dPoint&() const
{
return point;
}