-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
372 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,7 @@ | |
|
||
|
||
__all__ = ["HOME", "DATA", "DOCS", "TEMP"] | ||
|
||
__all_plugins__ = [ | ||
"compas_ifc.brep", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from .tessellatedbrep import TessellatedBrep | ||
from .tessellatedbrepobject import TessellatedBrepObject | ||
from compas.plugins import plugin | ||
from compas.scene import register | ||
|
||
|
||
@plugin(category="factories", requires=["compas_viewer"]) | ||
def register_scene_objects(): | ||
register(TessellatedBrep, TessellatedBrepObject, context="Viewer") | ||
|
||
|
||
__all__ = ["TessellatedBrep", "TessellatedBrepObject"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from compas.geometry import Geometry | ||
from compas.geometry import transform_points_numpy | ||
import numpy as np | ||
|
||
|
||
class TessellatedBrep(Geometry): | ||
def __init__(self, vertices=None, edges=None, faces=None, **kwargs): | ||
super().__init__(**kwargs) | ||
if vertices is None: | ||
vertices = [] | ||
if edges is None: | ||
edges = [] | ||
if faces is None: | ||
faces = [] | ||
self.vertices = np.array(vertices).reshape(-1, 3) | ||
self.edges = np.array(edges).reshape(-1, 2) | ||
self.faces = np.array(faces).reshape(-1, 3) | ||
|
||
def transform(self, transformation): | ||
self.vertices = transform_points_numpy(self.vertices, transformation) | ||
|
||
def to_vertices_and_faces(self): | ||
return self.vertices, self.faces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from compas_viewer.scene import ViewerSceneObject | ||
from .tessellatedbrep import TessellatedBrep | ||
from compas.datastructures import Mesh | ||
import numpy as np | ||
|
||
|
||
class TessellatedBrepObject(ViewerSceneObject): | ||
def __init__(self, tessellatedbrep: TessellatedBrep, facecolors=None, **kwargs): | ||
super().__init__(item=tessellatedbrep, **kwargs) | ||
self.tessellatedbrep = tessellatedbrep | ||
self.facecolors = facecolors | ||
self.use_rgba = True | ||
|
||
# TODO: it is not facecolors, it is verexcolor | ||
if not self.facecolors: | ||
self.facecolors = [[0.5, 0.5, 0.5, 1.0] for _ in range(len(self.tessellatedbrep.faces) * 3)] | ||
|
||
def _read_lines_data(self): | ||
positions = self.tessellatedbrep.vertices | ||
elements = self.tessellatedbrep.edges | ||
colors = [] | ||
default_color = self.linescolor["_default"] | ||
colors = np.full(shape=(len(elements), 3), fill_value=default_color) | ||
return positions.tolist(), colors.tolist(), elements.tolist() | ||
|
||
def _read_frontfaces_data(self): | ||
positions = self.tessellatedbrep.vertices[self.tessellatedbrep.faces].reshape(-1, 3).tolist() | ||
elements = np.arange(len(positions) * 3).reshape(-1, 3).tolist() | ||
colors = [color[:3] for color in self.facecolors] | ||
opacities = [color[3] for color in self.facecolors] | ||
return positions, colors, opacities, elements | ||
|
||
def _read_backfaces_data(self): | ||
positions = self.tessellatedbrep.vertices[self.tessellatedbrep.faces].reshape(-1, 3).tolist() | ||
elements = np.arange(len(positions) * 3).reshape(-1, 3) | ||
elements = elements[:, ::-1].tolist() | ||
colors = [color[:3] for color in self.facecolors] | ||
opacities = [color[3] for color in self.facecolors] | ||
return positions, colors, opacities, elements | ||
|
||
def to_mesh(self): | ||
return Mesh.from_vertices_and_faces(self.tessellatedbrep.vertices, self.tessellatedbrep.faces) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.