Kstars

RangeConvex.h
1#ifndef _RangeConvex_h
2#define _RangeConvex_h
3
4//# Filename: RangeConvex.h
5//#
6//# Classes defined here: RangeConvex
7//#
8//#
9//# Author: Peter Z. Kunszt, based on A. Szalay's code
10//#
11//# Date: October 16, 1998
12//#
13//# SPDX-FileCopyrightText: 2000 Peter Z. Kunszt Alex S. Szalay, Aniruddha R. Thakar
14//# The Johns Hopkins University
15//#
16//# Modification History:
17//#
18//# Oct 18, 2001 : Dennis C. Dinge -- Replaced ValVec with std::vector
19//#
20
21class RangeConvex;
23class SpatialSign;
24
25#include "SpatialConstraint.h"
26#include "SpatialIndex.h"
27#include "SpatialSign.h"
28
29#include <HtmRange.h>
30
31typedef std::vector<uint64> ValueVectorUint64;
32
33/** Enumerator. Define the return values of an intersection */
34
35enum SpatialMarkup
36{
37 /// Uncertain
38 dONTKNOW,
39 /// Triangle partially intersected
40 pARTIAL,
41 /// All of the triangle is inside queried area
42 fULL,
43 /// Triangle is outside the queried area
44 rEJECT
45};
46
47//########################################################################
48//#
49//# Spatial Convex class
50//#
51/**
52 A spatial convex is composed of spatial constraints. It does not
53 necessarily define a continuous area on the sphere since it is a
54 3D-convex of planar intersections which may intersect with the
55 unit sphere at disjoint locations. Especially 'negative'
56 constraints tend to tear 'holes' into the convex area.
57*/
58
59class LINKAGE RangeConvex
60{
61 public:
62 /// Default Constructor
64
65 /// Constructor from a triangle
66 RangeConvex(const SpatialVector *v1, const SpatialVector *v2, const SpatialVector *v3);
67
68 /// Constructor from a rectangle
69 RangeConvex(const SpatialVector *v1, const SpatialVector *v2, const SpatialVector *v3, const SpatialVector *v4);
70
71 /// Add a constraint
72 void add(SpatialConstraint &);
73
74 /// Simplify the convex, remove redundancies
75 void simplify();
76
77 /** Intersect with index. Result is given in a list of nodes. */
78 void intersect(const SpatialIndex *index, HtmRange *hr);
79
80 void setOlevel(int level) { olevel = level; };
81
82 protected:
83 HtmRange *hr;
84 int olevel;
85 Sign sign_ { zERO };
86
87 // Do the intersection (common function for overloaded intersect())
88 // Simplification routine for zERO convexes. This is called by
89 // simplify() in case we have all zERO constraints.
90 void simplify0();
91
92 // saveTrixel: saves the given htmid for later output
93 void saveTrixel(uint64 htmid);
94
95 // testTrixel: Test the nodes of the index if the convex hits it
96 // the argument gives the index of the nodes_ array to specify the QuadNode
97 SpatialMarkup testTrixel(uint64 nodeIndex);
98
99 // test each quadnode for intersections. Calls testTriangle after having
100 // tested the vertices using testVertex.
101 SpatialMarkup testNode(uint64 id);
102
103 // SpatialMarkup testNode(const struct SpatialIndex::QuadNode *indexNode);
104 SpatialMarkup testNode(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2);
105
106 // testTriangle: tests a triangle given by 3 vertices if
107 // it intersects the convex. Here the whole logic of deciding
108 // whether it is partial, full, swallowed or unknown is handled.
109 SpatialMarkup testTriangle(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2, int vsum);
110
111 // test a triangle's subtriangles whether they are partial.
112 // If level is nonzero, recurse: subdivide the
113 // triangle according to our rules and test each subdivision.
114 // (our rules are: each subdivided triangle has to be given
115 // ordered counter-clockwise, 0th index starts off new 0-node,
116 // 1st index starts off new 1-node, 2nd index starts off new 2-node
117 // middle triangle gives new 3-node.)
118 // if we are at the bottom, set this id's leafindex in partial bitlist.
119 void testPartial(size_t level, uint64 id, const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2,
120 int previousPartials);
121
122 // Test for constraint relative position; intersect, one in the
123 // other, disjoint.
124 int testConstraints(size_t i, size_t j);
125
126 // Test if vertices are inside the convex for a node.
127 int testVertex(const SpatialVector &v);
128 int testVertex(const SpatialVector *v);
129
130 // testHole : look for 'holes', i.e. negative constraints that have their
131 // centers inside the node with the three corners v0,v1,v2.
132 bool testHole(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2);
133
134 // testEdge0: test the edges of the triangle against the edges of the
135 // zERO convex. The convex is stored in corners_ so that the convex
136 // is always on the left-hand-side of an edge corners_(i) - corners_(i+1).
137 // (just like the triangles). This makes testing for intersections with
138 // the edges easy.
139 bool testEdge0(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2);
140
141 // testEdge: look whether one of the constraints intersects with one of
142 // the edges of node with the corners v0,v1,v2.
143 bool testEdge(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2);
144
145 // eSolve: solve the quadratic equation for the edge v1,v2 of
146 // constraint[cIndex]
147 bool eSolve(const SpatialVector &v1, const SpatialVector &v2, size_t cIndex);
148
149 // Test if bounding circle intersects with a constraint
150 bool testBoundingCircle(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2);
151
152 // Test if a constraint intersects the edges
153 bool testEdgeConstraint(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2, size_t cIndex);
154
155 // Look for any positive constraint that does not intersect the edges
156 size_t testOtherPosNone(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2);
157
158 // Test for a constraint lying inside or outside of triangle
159 bool testConstraintInside(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2, size_t cIndex);
160
161 // Test for a vector lying inside or outside of triangle
162 bool testVectorInside(const SpatialVector &v0, const SpatialVector &v1, const SpatialVector &v2, SpatialVector &v);
163
164 std::vector<SpatialConstraint> constraints_; // The vector of constraints
165 const SpatialIndex *index_; // A pointer to the index
166 std::vector<SpatialVector> corners_;
167 SpatialConstraint boundingCircle_; // For zERO convexes, the bc.
168 size_t addlevel_; // additional levels to calculate
169 ValueVectorUint64 *plist_; // list of partial node ids
170 private:
171 // Disallow copying and assignemnt
172 RangeConvex(const RangeConvex &);
173 RangeConvex &operator=(const RangeConvex &);
174};
175
176#endif
A spatial convex is composed of spatial constraints.
Definition RangeConvex.h:60
The Constraint is really a cone on the sky-sphere.
SpatialIndex is a quad tree of spherical triangles.
SpatialVector is a 3D vector usually living on the surface of the sphere.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:53:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.