fix line scale on receive; separate Mesh Multipatches on Send (exception case, TODO)
This commit is contained in:
@@ -46,30 +46,37 @@ def polygonToSpeckleMesh(geom, index: int, layer, multitype: bool, dataStorage):
|
||||
for i, p in enumerate(geom):
|
||||
# print("____start enumerate feature")
|
||||
# print(p) #<geoprocessing array object object at 0x0000026796C77110>
|
||||
# print(p)
|
||||
boundary, voids = getPolyBoundaryVoids(p, layer, dataStorage)
|
||||
# print(boundary)
|
||||
# print(voids)
|
||||
polyBorder = speckleBoundaryToSpecklePts(boundary)
|
||||
# print(polyBorder)
|
||||
voidsAsPts = []
|
||||
for v in voids:
|
||||
pts = speckleBoundaryToSpecklePts(v)
|
||||
voidsAsPts.append(pts)
|
||||
# print(voidsAsPts)
|
||||
total_vert, vertices_x, faces_x, colors_x = meshPartsFromPolygon(
|
||||
polyBorder, voidsAsPts, existing_vert, index, layer, dataStorage
|
||||
)
|
||||
boundaries, voids = getPolyBoundaryVoids(p, layer, dataStorage)
|
||||
# boundary = boundaries[0]
|
||||
for boundary in boundaries:
|
||||
# print(boundary)
|
||||
# print(voids)
|
||||
polyBorder = speckleBoundaryToSpecklePts(boundary)
|
||||
print(boundary.as_points())
|
||||
# print(polyBorder)
|
||||
if polyBorder is None or (
|
||||
isinstance(polyBorder, list) and len(polyBorder) < 3
|
||||
):
|
||||
continue
|
||||
# print(existing_vert)
|
||||
voidsAsPts = []
|
||||
for v in voids:
|
||||
pts = speckleBoundaryToSpecklePts(v)
|
||||
voidsAsPts.append(pts)
|
||||
# print(voidsAsPts)
|
||||
total_vert, vertices_x, faces_x, colors_x = meshPartsFromPolygon(
|
||||
polyBorder, voidsAsPts, existing_vert, index, layer, dataStorage
|
||||
)
|
||||
|
||||
existing_vert += total_vert
|
||||
vertices.extend(vertices_x)
|
||||
faces.extend(faces_x)
|
||||
colors.extend(colors_x)
|
||||
existing_vert += total_vert
|
||||
vertices.extend(vertices_x)
|
||||
faces.extend(faces_x)
|
||||
colors.extend(colors_x)
|
||||
|
||||
# print("Colors: ")
|
||||
# print(colors)
|
||||
# print(faces)
|
||||
# print(vertices)
|
||||
# print(colors)
|
||||
mesh = constructMesh(vertices, faces, colors)
|
||||
# print(mesh)
|
||||
if mesh is not None:
|
||||
@@ -88,33 +95,39 @@ def polygonToSpeckleMesh(geom, index: int, layer, multitype: bool, dataStorage):
|
||||
|
||||
|
||||
def getPolyBoundaryVoids(feature, layer, dataStorage, x_form=None):
|
||||
# print("__getPolyBoundaryVoids__")
|
||||
print("__getPolyBoundaryVoids__")
|
||||
voids: List[Union[None, Polyline, Arc, Line, Polycurve]] = []
|
||||
boundary = None
|
||||
pointList = []
|
||||
all_boundaries = []
|
||||
try:
|
||||
# if multiType is False: # Multipolygon
|
||||
# boundary = anyLineToSpeckle(feature, feature, layer, dataStorage, xform_vars)
|
||||
|
||||
# else:
|
||||
# print("multi type")
|
||||
for i, pt in enumerate(feature):
|
||||
# print(pt) # 284394.58100903 5710688.11602606 NaN NaN
|
||||
# for pt in p:
|
||||
# print(pt)
|
||||
if pt == None and boundary == None: # first break
|
||||
boundary = polylineFromVerticesToSpeckle(
|
||||
pointList, True, feature, layer, dataStorage
|
||||
)
|
||||
# print("__Boundary:")
|
||||
# print(boundary) # Polyline
|
||||
pointList = []
|
||||
all_boundaries.append(boundary)
|
||||
elif pt == None and boundary != None: # breaks btw voids
|
||||
void = polylineFromVerticesToSpeckle(
|
||||
pointList, True, feature, layer, dataStorage
|
||||
)
|
||||
voids.append(void)
|
||||
pointList = []
|
||||
elif (
|
||||
len(pointList) > 0
|
||||
and pt.X == pointList[0].X
|
||||
and pt.Y == pointList[0].Y
|
||||
and pt.Z == pointList[0].Z
|
||||
): # new condition
|
||||
# if multiple boundaries
|
||||
new_boundary = polylineFromVerticesToSpeckle(
|
||||
pointList, True, feature, layer, dataStorage
|
||||
)
|
||||
pointList = []
|
||||
# print(new_boundary)
|
||||
all_boundaries.append(new_boundary)
|
||||
elif pt != None: # add points to whatever list (boundary or void)
|
||||
pointList.append(pt)
|
||||
|
||||
@@ -128,10 +141,11 @@ def getPolyBoundaryVoids(feature, layer, dataStorage, x_form=None):
|
||||
boundary = polylineFromVerticesToSpeckle(
|
||||
pointList, True, feature, layer, dataStorage
|
||||
)
|
||||
all_boundaries.append(boundary)
|
||||
|
||||
except Exception as e:
|
||||
logToUser(str(e), level=2, func=inspect.stack()[0][3])
|
||||
return boundary, voids
|
||||
return all_boundaries, voids
|
||||
|
||||
|
||||
def multiPolygonToSpeckle(geom, index: str, layer, multiType: bool, dataStorage):
|
||||
@@ -183,7 +197,8 @@ def polygonToSpeckle(geom, feature, index: int, layer, dataStorage, x_form):
|
||||
print("___Polygon to Speckle____")
|
||||
# print(geom) # array
|
||||
|
||||
boundary, voids = getPolyBoundaryVoids(geom, layer, dataStorage, x_form)
|
||||
boundaries, voids = getPolyBoundaryVoids(geom, layer, dataStorage, x_form)
|
||||
boundary = boundaries[0]
|
||||
# print(boundary)
|
||||
# print(voids)
|
||||
|
||||
|
||||
@@ -27,7 +27,10 @@ from speckle.speckle.converter.geometry.point import (
|
||||
pointToSpeckle,
|
||||
addZtoPoint,
|
||||
)
|
||||
from speckle.speckle.converter.geometry.utils import speckleArcCircleToPoints
|
||||
from speckle.speckle.converter.geometry.utils import (
|
||||
speckleArcCircleToPoints,
|
||||
specklePolycurveToPoints,
|
||||
)
|
||||
from speckle.speckle.converter.layers.utils import apply_reproject, get_scale_factor
|
||||
from speckle.speckle.utils.panel_logging import logToUser
|
||||
|
||||
@@ -109,7 +112,7 @@ def anyLineToSpeckle(geom, feature, layer, dataStorage, x_form=None):
|
||||
|
||||
# print(new_geom) # describe geometry object
|
||||
for p in new_geom:
|
||||
print(p) # array
|
||||
# print(p) # array
|
||||
for pt in p:
|
||||
# print(pt)
|
||||
if pt != None:
|
||||
@@ -527,6 +530,9 @@ def polylineToNative(
|
||||
if poly.closed is True:
|
||||
pts.append(pointToCoord(poly.as_points()[0]))
|
||||
|
||||
scale = get_scale_factor(poly.units)
|
||||
pts = [[pt[0] * scale, pt[1] * scale, pt[2] * scale] for pt in pts]
|
||||
|
||||
pts_coord_list = [arcpy.Point(*coords) for coords in pts]
|
||||
polyline = arcpy.Polyline(arcpy.Array(pts_coord_list), sr, has_z=True)
|
||||
# print(polyline.JSON)
|
||||
@@ -540,6 +546,9 @@ def lineToNative(line: Line, sr: arcpy.SpatialReference, dataStorage) -> arcpy.P
|
||||
print("___Line to Native___")
|
||||
try:
|
||||
pts = [pointToCoord(pt) for pt in [line.start, line.end]]
|
||||
scale = get_scale_factor(line.units)
|
||||
pts = [[pt[0] * scale, pt[1] * scale, pt[2] * scale] for pt in pts]
|
||||
|
||||
line = arcpy.Polyline(
|
||||
arcpy.Array([arcpy.Point(*coords) for coords in pts]), sr, has_z=True
|
||||
)
|
||||
@@ -614,6 +623,10 @@ def circleToNative(
|
||||
pt.units = "m"
|
||||
points.append(pointToCoord(pt))
|
||||
points.append(points[0])
|
||||
|
||||
scale = get_scale_factor(poly.units)
|
||||
points = [[pt[0] * scale, pt[1] * scale, pt[2] * scale] for pt in points]
|
||||
|
||||
curve = arcpy.Polyline(
|
||||
arcpy.Array([arcpy.Point(*coords) for coords in points]), sr, has_z=True
|
||||
)
|
||||
@@ -709,6 +722,10 @@ def arcToNativePolyline(
|
||||
try:
|
||||
pointsSpeckle = speckleArcCircleToPoints(poly)
|
||||
points = [pointToCoord(p) for p in pointsSpeckle]
|
||||
|
||||
scale = get_scale_factor(poly.units)
|
||||
points = [[pt[0] * scale, pt[1] * scale, pt[2] * scale] for pt in points]
|
||||
|
||||
curve = arcpy.Polyline(
|
||||
arcpy.Array([arcpy.Point(*coords) for coords in points]), sr, has_z=True
|
||||
)
|
||||
|
||||
@@ -875,7 +875,7 @@ def featureColorfromNativeRenderer(index: int, arcLayer: arcLayer) -> int:
|
||||
sym = arcLayer.symbology
|
||||
|
||||
if sym.renderer.type == "SimpleRenderer":
|
||||
print("SimpleRenderer")
|
||||
#print("SimpleRenderer")
|
||||
color = sym.renderer.symbol.color
|
||||
|
||||
elif sym.renderer.type == "UniqueValueRenderer":
|
||||
|
||||
@@ -406,7 +406,7 @@ class SpeckleGIS:
|
||||
isinstance(layers, list) and len(layers) == 0
|
||||
): # len(selectedLayerNames) == 0:
|
||||
logToUser(
|
||||
"No layers selected",
|
||||
"No valid layers selected",
|
||||
level=1,
|
||||
func=inspect.stack()[0][3],
|
||||
plugin=self.dockwidget,
|
||||
|
||||
Reference in New Issue
Block a user