24
24
import java .util .ArrayList ;
25
25
26
26
import org .hipparchus .geometry .euclidean .twod .Euclidean2D ;
27
+ import org .hipparchus .geometry .euclidean .twod .Line ;
27
28
import org .hipparchus .geometry .euclidean .twod .PolygonsSet ;
29
+ import org .hipparchus .geometry .euclidean .twod .SubLine ;
28
30
import org .hipparchus .geometry .euclidean .twod .Vector2D ;
29
- import org .hipparchus .geometry .partitioning .AbstractSubHyperplane ;
30
31
import org .hipparchus .geometry .partitioning .BSPTree ;
31
32
import org .hipparchus .geometry .partitioning .BSPTreeVisitor ;
32
33
import org .hipparchus .geometry .partitioning .BoundaryAttribute ;
33
34
import org .hipparchus .geometry .partitioning .RegionFactory ;
34
- import org .hipparchus .geometry .partitioning .SubHyperplane ;
35
35
import org .hipparchus .util .FastMath ;
36
36
import org .hipparchus .util .MathUtils ;
37
37
@@ -123,7 +123,7 @@ private boolean pointIsBetween(final Vector2D[] loop, final int n, final int i)
123
123
}
124
124
125
125
/** Visitor projecting the boundary facets on a plane. */
126
- private class BoundaryProjector implements BSPTreeVisitor <Euclidean3D , Vector3D > {
126
+ private class BoundaryProjector implements BSPTreeVisitor <Euclidean3D , Vector3D , Plane , SubPlane > {
127
127
128
128
/** Projection of the polyhedrons set on the plane. */
129
129
private PolygonsSet projected ;
@@ -141,16 +141,16 @@ private class BoundaryProjector implements BSPTreeVisitor<Euclidean3D, Vector3D>
141
141
142
142
/** {@inheritDoc} */
143
143
@ Override
144
- public Order visitOrder (final BSPTree <Euclidean3D , Vector3D > node ) {
144
+ public Order visitOrder (final BSPTree <Euclidean3D , Vector3D , Plane , SubPlane > node ) {
145
145
return Order .MINUS_SUB_PLUS ;
146
146
}
147
147
148
148
/** {@inheritDoc} */
149
149
@ Override
150
- public void visitInternalNode (final BSPTree <Euclidean3D , Vector3D > node ) {
150
+ public void visitInternalNode (final BSPTree <Euclidean3D , Vector3D , Plane , SubPlane > node ) {
151
151
@ SuppressWarnings ("unchecked" )
152
- final BoundaryAttribute <Euclidean3D , Vector3D > attribute =
153
- (BoundaryAttribute <Euclidean3D , Vector3D >) node .getAttribute ();
152
+ final BoundaryAttribute <Euclidean3D , Vector3D , Plane , SubPlane > attribute =
153
+ (BoundaryAttribute <Euclidean3D , Vector3D , Plane , SubPlane >) node .getAttribute ();
154
154
if (attribute .getPlusOutside () != null ) {
155
155
addContribution (attribute .getPlusOutside ());
156
156
}
@@ -161,23 +161,18 @@ public void visitInternalNode(final BSPTree<Euclidean3D, Vector3D> node) {
161
161
162
162
/** {@inheritDoc} */
163
163
@ Override
164
- public void visitLeafNode (final BSPTree <Euclidean3D , Vector3D > node ) {
164
+ public void visitLeafNode (final BSPTree <Euclidean3D , Vector3D , Plane , SubPlane > node ) {
165
165
}
166
166
167
167
/** Add he contribution of a boundary facet.
168
168
* @param facet boundary facet
169
169
*/
170
- private void addContribution (final SubHyperplane < Euclidean3D , Vector3D > facet ) {
170
+ private void addContribution (final SubPlane facet ) {
171
171
172
- // extract the vertices of the facet
173
- final AbstractSubHyperplane <Euclidean3D , Vector3D , Euclidean2D , Vector2D > absFacet =
174
- (AbstractSubHyperplane <Euclidean3D , Vector3D , Euclidean2D , Vector2D >) facet ;
175
- final Plane plane = (Plane ) facet .getHyperplane ();
176
-
177
- final double scal = plane .getNormal ().dotProduct (w );
172
+ final double scal = facet .getHyperplane ().getNormal ().dotProduct (w );
178
173
if (FastMath .abs (scal ) > 1.0e-3 ) {
179
174
Vector2D [][] vertices =
180
- ((PolygonsSet ) absFacet .getRemainingRegion ()).getVertices ();
175
+ ((PolygonsSet ) facet .getRemainingRegion ()).getVertices ();
181
176
182
177
if (scal < 0 ) {
183
178
// the facet is seen from the back of the plane,
@@ -205,21 +200,21 @@ private void addContribution(final SubHyperplane<Euclidean3D, Vector3D> facet) {
205
200
}
206
201
207
202
// compute the projection of the facet in the outline plane
208
- final ArrayList <SubHyperplane < Euclidean2D , Vector2D > > edges = new ArrayList <>();
203
+ final ArrayList <SubLine > edges = new ArrayList <>();
209
204
for (Vector2D [] loop : vertices ) {
210
205
final boolean closed = loop [0 ] != null ;
211
206
int previous = closed ? (loop .length - 1 ) : 1 ;
212
- final Vector3D previous3D = plane .toSpace (loop [previous ]);
207
+ final Vector3D previous3D = facet . getHyperplane () .toSpace (loop [previous ]);
213
208
int current = (previous + 1 ) % loop .length ;
214
209
Vector2D pPoint = new Vector2D (previous3D .dotProduct (u ), previous3D .dotProduct (v ));
215
210
while (current < loop .length ) {
216
211
217
- final Vector3D current3D = plane .toSpace (loop [current ]);
212
+ final Vector3D current3D = facet . getHyperplane () .toSpace (loop [current ]);
218
213
final Vector2D cPoint = new Vector2D (current3D .dotProduct (u ),
219
214
current3D .dotProduct (v ));
220
215
final org .hipparchus .geometry .euclidean .twod .Line line =
221
216
new org .hipparchus .geometry .euclidean .twod .Line (pPoint , cPoint , tolerance );
222
- SubHyperplane < Euclidean2D , Vector2D > edge = line .wholeHyperplane ();
217
+ SubLine edge = line .wholeHyperplane ();
223
218
224
219
if (closed || (previous != 1 )) {
225
220
// the previous point is a real vertex
@@ -249,7 +244,8 @@ private void addContribution(final SubHyperplane<Euclidean3D, Vector3D> facet) {
249
244
final PolygonsSet projectedFacet = new PolygonsSet (edges , tolerance );
250
245
251
246
// add the contribution of the facet to the global outline
252
- projected = (PolygonsSet ) new RegionFactory <Euclidean2D , Vector2D >().union (projected , projectedFacet );
247
+ final RegionFactory <Euclidean2D , Vector2D , Line , SubLine > factory = new RegionFactory <>();
248
+ projected = (PolygonsSet ) factory .union (projected , projectedFacet );
253
249
254
250
}
255
251
}
0 commit comments