id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
35,771
document.lisp
lisp-mirror_gendl/geom-base/drawing/source/document.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) ;; ;; FLAG -- check whether this is still being used. ;; (defun print-document (type) (the-object (make-object type) print-pdf)) (define-object document (base-object) :input-slots ((pages nil)) :functions ((print-pdf (&key (output-file (format nil "/tmp/~s.pdf" (the type)))) (with-format (pdf-multipage output-file) (write-the cad-output))))) (define-lens (pdf document)() :output-functions ((cad-output () (dolist (page (the pages)) (let ((width (coerce (the-object page page-width) 'double-float)) (length (coerce (the-object page page-length) 'double-float))) (pdf:with-page (:bounds (make-array 4 :initial-contents (list 0 0 width length))) (pdf:with-saved-state (pdf:translate (half (the-object page page-width)) (half (the-object page page-length))) (write-the-object page cad-output))))))))
1,902
Common Lisp
.lisp
47
34.297872
75
0.655247
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
178d41311cbaf6c193916c4b99ad289f86948183cbdde587af110b65fd72c791
35,771
[ -1 ]
35,772
base-view.lisp
lisp-mirror_gendl/geom-base/drawing/source/base-view.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (defparameter *previous-scale* 1) (defparameter *center-circ* nil) ;; ;; FLAG -- this will move back to internal codebase on the next build. ;; (define-object surf:arc-curve ()) (define-object surf:curve () :computed-slots ((knot-vector nil))) (define-object surf:linear-curve ()) (define-object base-drawing (base-object) :documentation (:description "Generic container object for displaying one or more scaled transformed views of geometric or text-based entities. The contained views are generally of type <tt>base-view</tt>. In a GWL application-mixin, you can include one object of this type in the ui-display-list-leaves. For the PDF output-format, you can also use the cad-output output-function to write the drawing as a PDF document. Since base-drawing is inherently a 2D object, only the top view (getf *standard-views* :top) makes sense for viewing it." :examples "<pre> (in-package :gdl-user) (define-object cylinder-sample (cylinder) :computed-slots ((display-controls (list :color :pink-spicy)) (length 10) (radius 3) (number-of-sections 25))) (define-object base-drawing-sample (base-drawing) :objects ((main-view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :object-roots (list (the surf))) (surf :type 'cylinder-sample :hidden? t))) (generate-sample-drawing :objects (make-object 'base-drawing-sample)) </pre>") :input-slots ( (empty-display-list-message nil) ;;(touched-geometry nil) (width (the page-width)) (length (the page-length)) (height 0) ("Number in PDF Points. Left-to-right width of the paper being represented by this drawing. The default is (* 8.5 72) points, or 8.5 inches, corresponding to US standard letter-size paper." page-width (* 8.5 72)) ("Number in PDF Points. Front-to-back (or top-to-bottom) length of the paper being represented by this drawing. The default is (* 11 72) points, or 11 inches, corresponding to US standard letter-size paper." page-length (* 11 72)) (%corners% (list (the (vertex :top :left :rear)) (the (vertex :top :right :rear)) (the (vertex :top :right :front)) (the (vertex :top :left :front))))) :computed-slots ( (%vertex-array% (make-array 4 :initial-contents (the %corners%))) (views (remove-if-not #'(lambda(child) (typep child 'base-view)) (append (the children) (the hidden-children)))) (objects (apply #'append (mapsend (the views) :objects))) (object-roots (apply #'append (mapsend (the views) :object-roots))) (annotation-objects (apply #'append (mapsend (the views) :annotation-objects))) (user-center nil))) (define-object base-view (base-object) :documentation (:description "Generic container object for displaying a scaled transformed view of geometric or text-based objects. <tt>Base-view</tt> can be used by itself or as a child of a <tt>base-drawing</tt> In a GWL application-mixin, you can include an object of this type in the ui-display-list-leaves. For the PDF output-format, you can also use the cad-output output-function to write the view as a PDF document. Since base-view is inherently a 2D object, only the top view (getf *standard-views* :top) makes sense for viewing it." :examples "<pre> (in-package :gdl-user) (define-object box-with-two-viewed-drawing (base-object) :objects ((drawing :type 'two-viewed-drawing :objects-to-draw (list (the box) (the length-dim))) (length-dim :type 'horizontal-dimension :hidden? t :start-point (the box (vertex :rear :top :left)) :end-point (the box (vertex :rear :top :right))) (box :type 'box :hidden? t :length 5 :width 10 :height 15))) (define-object two-viewed-drawing (base-drawing) :input-slots (objects-to-draw) :objects ((main-view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :length (half (the length)) :center (translate (the center) :rear (half (the-child length))) :objects (the objects-to-draw)) (top-view :type 'base-view :projection-vector (getf *standard-views* :top) :length (* 0.30 (the length)) :objects (the objects-to-draw)))) (generate-sample-drawing :objects (the-object (make-object 'box-with-two-viewed-drawing) drawing top-view)) </pre>") :input-slots ( ("3D-point. Center of the view box. Specify this or corner, not both. NOTE that the center is no longer defaulting (so that it can self-compute properly when corner is specified), so it is necessary to explicitly give either start or center for base-view." center (if *center-circ* (the parent center) (translate (the corner) :right (half (the width)) :front (half (the length))))) ("3D-point. Top left (i.e. rear left from top view) of the view box. Specify this or center, not both." corner (let ((*center-circ* t)) (translate (the center) :left (half (the width)) :rear (half (the length)) ))) ;;(touched-geometry nil) ("List of GDL objects. The leaves from each of these objects will be displayed in each view by default." object-roots nil) ("List of GDL objects. These objects will be displayed in each view by default." objects nil) ("List of GDL objects. These objects are immune from view scaling and transform computations and so can freely refer to the view-scale, view-center, and other view information for self-scaling views. Defaults to NIL." immune-objects nil) ("List of GDL objects. These objects will be displayed in each view by default, with no scaling or transform (i.e. they are in Drawing space." annotation-objects nil) ("Number. Ratio of drawing scale (in points) to model scale for this view. Defaults to being auto-computed." view-scale (getf (the view-contents-data) :view-scale)) ("3D Point in Model space. Point relative to each object's center to use as center of the view." ;; ;; FLAG -- convert this to model coordinates, then back to view-coords in the output-functions. ;; view-center (getf (the view-contents-data) :view-center)) ("3D Unitized Vector. Direction of camera pointing to model (the object-roots and/or the objects) to create this view. The view is automatically ``twisted''about this vector to result in ``up'' being as close as possible to the Z vector, unless this vector is parallel to the Z vector in which case ``up'' is taken to be the Y (rear) vector. This vector is normally taken from the <tt>*standard-views*</tt> built-in GDL parameter. Defaults to <tt>(getf *standard-views* :top)</tt>, which is the vector [0, 0, 1]." projection-vector (getf *standard-views* :top)) ("Number in Drawing scale (e.g. points). Amount of margin on left and right of page when <tt>view-scale</tt> is to be computed automatically. Defaults to 25." left-margin (* (the width) 25/612)) ("Number in Drawing scale (e.g. points). Amount of margin on front and rear of page when <tt>view-scale</tt> is to be computed automatically. Defaults to 25." front-margin (* (the length) 25/792)) ("Boolean. Determines whether a rectangular border box is drawn around the view, with the view's length and width. Defaults to nil." border-box? nil) (user-scale nil :settable :defaulting) ("3D Vector. For a top view, this vector specifies the direction that the rear of the box should be facing. Defaults to <tt>*nominal-y-vector*</tt>." snap-to *nominal-y-vector*)) :computed-slots ( (view-scale-total (cond ((the user-scale) (* (the view-scale) (the user-scale))) (t (the view-scale)))) (immune-objects-hash (let ((ht (glisp:make-sans-value-hash-table :size (length (the immune-objects))))) (dolist (object (the immune-objects) ht) (setf (gethash object ht) t)))) ;; ;; FLAG -- watch out for memory issues with vertex-array-2d captured here. ;; ;; (2d-boxes (remove nil (mapsend (the object-caches) :2d-bounding-box))) (view-contents-data (let* ((2d-boxes (the 2d-boxes))) (if 2d-boxes (let (xmin xmax ymin ymax) (dolist (2d-box 2d-boxes) (let ((new-xmin (getf 2d-box :xmin)) (new-ymin (getf 2d-box :ymin)) (new-xmax (getf 2d-box :xmax)) (new-ymax (getf 2d-box :ymax))) (when (or (null xmin) (< new-xmin xmin)) (setq xmin new-xmin)) (when (or (null ymin) (< new-ymin ymin)) (setq ymin new-ymin)) (when (or (null xmax) (> new-xmax xmax)) (setq xmax new-xmax)) (when (or (null ymax) (> new-ymax ymax)) (setq ymax new-ymax)))) (let ((x-spread (- xmax xmin)) (y-spread (- ymax ymin)) (printable-x (- (the width) (twice (the left-margin)))) (printable-y (- (the length) (twice (the front-margin))))) (let ((scale (cond ((and (zerop x-spread) (zerop y-spread)) (warn "No Information to Determine the view-scale -- defaulting to 1.") 1) ((zerop x-spread) (/ printable-y y-spread)) ((zerop y-spread) (/ printable-x x-spread)) (t (min (/ printable-x x-spread) (/ printable-y y-spread))))) (center (keyed-transform*vector (the view-transform-inverse) (make-point (+ xmin (half x-spread)) (+ ymin (half y-spread)) 0) :snap-to (the snap-to) ))) (list :view-scale scale :view-center center)))) (progn (warn "No objects of substance in the view. Cannot auto-compute a scale or center") (list :view-scale 1 :view-center (keyed-transform*vector (the view-transform-inverse) (make-point 0 0 0) :snap-to (the snap-to))))))) (view-transform (view-transform (the projection-vector) :snap-to (the snap-to))) (view-transform-inverse (transpose-keyed-transform (the view-transform) :snap-to (the snap-to))) (leaf-objects-from-roots (remove-if #'(lambda(obj) (or (typep obj 'null-part) ;;(typep obj 'outline-specialization-mixin) )) (let ((leaves (apply #'append (mapcar #'(lambda(object) (if (typep object 'gdl::gdl-basis) (the-object object leaves) (list object))) (the object-roots))))) (append leaves (apply #'append (mapcar #'(lambda(leaf) (when (typep leaf 'outline-specialization-mixin) (the-object leaf outline-leaves))) leaves)))))) ;;(annotation-array (coerce (the annotation-objects) 'vector)) (annotation-array (remove-duplicates (coerce (append (the annotation-objects) (remove-if #'(lambda(obj) (or (typep obj 'null-part) (typep obj 'outline-specialization-mixin))) (apply #'append (mapcar #'(lambda(object) (when (typep object 'outline-specialization-mixin) (the-object object outline-leaves))) (the annotation-objects))))) 'vector))) (object-array (remove-duplicates (coerce (append (the objects) (remove-if #'(lambda(obj) (or (typep obj 'null-part) (typep obj 'outline-specialization-mixin) )) (apply #'append (mapcar #'(lambda(object) (when (typep object 'outline-specialization-mixin) (the-object object outline-leaves))) (the objects)))) (the leaf-objects-from-roots)) 'vector)))) :hidden-objects ((border-box :type 'box) (annotation-caches :type 'view-object-cache :sequence (:size (length (the annotation-array))) :projection-vector (getf *standard-views* :top) :view-transform (view-transform :top) ;;:view-transform (view-transform :top :snap-to (the snap-to)) ;;:snap-to (the snap-to) ;;:snap-to-y? (coincident-point? (the snap-to) *nominal-y-vector*) :snap-to-y? nil :scale? nil :object (svref (the annotation-array) (the-child index))) (object-caches :type 'view-object-cache :sequence (:size (length (the object-array))) :view-scale (the view-scale-total) :pass-down (projection-vector view-transform ;;touched-geometry snap-to) :snap-to-y? (coincident-point? (the snap-to) *nominal-y-vector*) :immune? (gethash (the-child object) (the immune-objects-hash)) :object (svref (the object-array) (the-child index)))) :functions (("3D Point. Takes point in view coordinates and returns corresponding point in model coordinates. :arguments (view-point \"3D Point. Point in view coordinates.\")" model-point (view-point) (let ((local-point (scalar*vector (/ (the view-scale-total)) view-point))) (add-vectors (the view-center) (keyed-transform*vector (the view-transform-inverse) local-point :snap-to (the snap-to))))) ("3D Point. Takes point in model coordinates and returns corresponding point in view coordinates. :arguments (model-point \"3D Point. Point in model coordinates.\")" view-point (model-point) (subtract-vectors (project-to-plane model-point (the view-scale-total) (the projection-vector) (the view-transform) :snap-to (the snap-to)) (project-to-plane (the view-center) (the view-scale-total) (the projection-vector) (the view-transform) :snap-to (the snap-to)))))) (define-object view-object-cache () :input-slots (object projection-vector view-transform view-scale (scale? t) ;;(touched-geometry nil) (immune? nil) (snap-to *nominal-y-vector*) snap-to-y? ) :computed-slots ((vertex-array-2d-scaled (if (the scale?) (let ((scale (the view-scale))) (map 'vector #'(lambda(point)(scalar*vector scale point)) (the vertex-array-2d))) (the vertex-array-2d))) (arcs-array-2d-scaled (if (the scale?) (let ((scale (the view-scale))) (map 'list #'(lambda(point)(scalar*vector scale point)) (the arcs-array-2d))) (the arcs-array-2d))) (curves-2d-scaled (when (the curves-2d) (list (if (the scale?) (list :degree (getf (the curves-2d) :degree) :knot-vector (getf (the curves-2d) :knot-vector) :weights (getf (the curves-2d) :weights) :control-points (let ((scale (the view-scale))) (mapcar #'(lambda(point) (scalar*vector scale point)) (getf (the curves-2d) :control-points)))) (the curves-2d))))) (path-info-2d-scaled (when (the path-info-2d) (if (the scale?) (let ((scale (the view-scale))) (mapcar #'(lambda(point) (if (keywordp point) point (scalar*vector scale point))) (the path-info-2d))) (the path-info-2d)))) ;; ;; FLAG -- fold code from this and next message into a method function ;; (curves-2d (when (and (typep (the object) 'surf:curve) (not (or (typep (the object) 'surf:arc-curve) (typep (the object) 'surf:linear-curve)))) (let ((control-points (the object control-points)) (weights (the object weights)) (knot-vector (the object knot-vector)) (degree (the object degree))) (list :degree degree :knot-vector knot-vector :weights weights :control-points (mapcar (if (and (keywordp (the view-transform)) (the snap-to-y?)) #'(lambda(point) (case (the view-transform) (:top (make-vector (get-x point) (get-y point))) (:bottom (make-vector (get-x point) (- (get-y point)))) (:rear (make-vector (- (get-x point)) (get-z point))) (:front (make-vector (get-x point) (get-z point))) (:right (make-vector (get-y point) (get-z point))) (:left (make-vector (- (get-y point)) (get-z point))))) #'(lambda(point) (subseq (project-to-plane point 1 (the projection-vector) (the view-transform) :snap-to (the snap-to)) 0 2))) control-points))))) (arcs-array-2d (let ((raw-points (mapsend (the object %arcs%) :center))) (map 'vector (if (and (keywordp (the view-transform)) (the snap-to-y?)) #'(lambda(point) ;; ;; FLAG this case basically repeats code from (defun keyed-transform*vector ...) ;; (case (the view-transform) (:top (make-vector (get-x point) (get-y point))) (:bottom (make-vector (get-x point) (- (get-y point)))) (:rear (make-vector (- (get-x point)) (get-z point))) (:front (make-vector (get-x point) (get-z point))) (:right (make-vector (get-y point) (get-z point))) (:left (make-vector (- (get-y point)) (get-z point))))) #'(lambda(point) (subseq (project-to-plane point 1 (the projection-vector) (the view-transform) :snap-to (the snap-to)) 0 2))) raw-points))) (vertex-array-2d (when (typep (the object) 'gdl::gdl-basis) (let ((raw-points (or (the object %vertex-array%) (the object %corners%)))) (map 'vector #'(lambda(point) ;; ;; FLAG this case basically repeats code from (defun keyed-transform*vector ...) ;; (if (and (keywordp (the view-transform)) (the snap-to-y?)) (case (the view-transform) (:top (subseq point 0 2)) ;;(make-vector (get-x point) (get-y point))) (:bottom (make-vector (get-x point) (- (get-y point)))) (:rear (make-vector (- (get-x point)) (get-z point))) (:front (make-vector (get-x point) (get-z point))) (:right (make-vector (get-y point) (get-z point))) (:left (make-vector (- (get-y point)) (get-z point)))) (subseq (project-to-plane point 1 (the projection-vector) (the view-transform) :snap-to (the snap-to)) 0 2))) raw-points)))) (path-info-2d (when (and (typep (the object) 'gdl::gdl-basis) (the object path-info)) (let ((raw-points (the object path-info))) (mapcar #'(lambda(point) ;; ;; FLAG this case basically repeats code from (defun keyed-transform*vector ...) ;; (if (keywordp point) point (if (and (keywordp (the view-transform)) (the snap-to-y?)) (case (the view-transform) (:top (subseq point 0 2)) ;;(make-vector (get-x point) (get-y point))) (:bottom (make-vector (get-x point) (- (get-y point)))) (:rear (make-vector (- (get-x point)) (get-z point))) (:front (make-vector (get-x point) (get-z point))) (:right (make-vector (get-y point) (get-z point))) (:left (make-vector (- (get-y point)) (get-z point)))) (subseq (project-to-plane point 1 (the projection-vector) (the view-transform) :snap-to (the snap-to)) 0 2)))) raw-points)))) (2d-bounding-box (unless (or (not (typep (the object) 'gdl::gdl-basis)) (the immune?)) (let* ((vertex-array-2d (the vertex-array-2d)) (xs (map 'list #'get-x vertex-array-2d)) (ys (map 'list #'get-y vertex-array-2d))) (when (and xs ys) (list :xmin (reduce #'min xs) :xmax (reduce #'max xs) :ymin (reduce #'min ys) :ymax (reduce #'max ys))))))) :functions ()) (defun project-to-plane (model-point view-scale projection-vector view-transform &key (snap-to *nominal-y-vector*)) (let ((drop-length (dot-vectors model-point projection-vector))) (scalar*vector view-scale (keyed-transform*vector view-transform (translate-along-vector model-point projection-vector (- drop-length)) :snap-to snap-to)))) (defun keyed-transform*vector (transform vector &key (snap-to *nominal-y-vector*)) (if (coincident-point? snap-to *nominal-y-vector*) (case transform (:top (make-vector (get-x vector) (get-y vector) 0)) (:bottom (make-vector (get-x vector) (- (get-y vector)) 0)) (:rear (make-vector (- (get-x vector)) (get-z vector) 0)) (:front (make-vector (get-x vector) (get-z vector) 0)) (:right (make-vector (get-y vector) (get-z vector) 0)) (:left (make-vector (- (get-y vector)) (get-z vector) 0)) (otherwise (matrix*vector transform vector))) (matrix*vector transform vector))) (defun view-transform (projection-vector &key (snap-to *nominal-y-vector*)) (if (and (eql projection-vector :top) (not (coincident-point? snap-to *nominal-y-vector*))) (let ((projection-vector (make-vector 0 0 1))) (or (gethash (list projection-vector snap-to) *view-transform-inverses-hash*) (setf (gethash (list projection-vector snap-to) *view-transform-inverses-hash*) (projection-vector-to-transform projection-vector :snap-to snap-to)))) (cond ((and (keywordp projection-vector) (coincident-point? snap-to *nominal-y-vector*)) projection-vector) ((and (coincident-point? projection-vector *nominal-z-vector*) (coincident-point? snap-to *nominal-y-vector*)) :top) ((coincident-point? projection-vector *nominal-y-vector*) :rear) ((coincident-point? projection-vector *nominal-x-vector*) :right) ((coincident-point? projection-vector *nominal-z-vector-r*) :bottom) ((coincident-point? projection-vector *nominal-y-vector-r*) :front) ((coincident-point? projection-vector *nominal-x-vector-r*) :left) (t (or (gethash (list projection-vector snap-to) *view-transform-inverses-hash*) (setf (gethash (list projection-vector snap-to) *view-transform-inverses-hash*) (projection-vector-to-transform projection-vector :snap-to snap-to))))))) (defun transpose-keyed-transform (transform &key (snap-to *nominal-y-vector*)) (if (keywordp transform) ;; ;; FLAG -- vet the special case of :bottom. ;; (case transform (:bottom :top) (otherwise (let ((projection-vector (getf *standard-views* transform))) (matrix:transpose-matrix (projection-vector-to-transform projection-vector :snap-to snap-to))))) (matrix:transpose-matrix transform))) (defun projection-vector-to-transform (projection-vector &key (snap-to *nominal-y-vector*)) (alignment :top projection-vector :rear (if (or (same-direction-vectors? projection-vector *nominal-z-vector*) (same-direction-vectors? projection-vector *nominal-z-vector-r*)) snap-to *nominal-z-vector*)))
26,602
Common Lisp
.lisp
500
40.1
146
0.57974
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c642acd4119f979f2be6998a1768f3c38c869600e39d1a3e1cfdd35e0a20dfc9
35,772
[ -1 ]
35,773
renderer-mixin.lisp
lisp-mirror_gendl/geom-base/drawing/source/renderer-mixin.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) ;; ;; FLAG -- vet the use of each slot in this object. ;; (define-object renderer-mixin () :documentation (:description "Object mixed into the base-view to compute required values to provide a rendered perspective view, as in VRML.") :computed-slots ((camera-distance-discount 0.8)) :input-slots ( ;;(camera-distance-discount 0.8) "List of GDL Objects. Roots of the leaf objects to be displayed in this renderer view." object-roots "List of GDL Objects. Leaves of the objects to be displayed in this renderer view." objects (background-color (lookup-color (getf *colors-default* :background) :format :decimal)) (zoom-factor-renderer 1) (view :trimetric) ("Number in angular degrees. The maximum angle of the view frustrum for perspective views. Defaults to 0.1 (which results in a near parallel projection with virtually no perspective effect)." field-of-view-default 45) ("List of Plists. Each plist contains, based on each entry in the <tt>view-vectors</tt>, keys: <ul> <li><tt>:point</tt> (camera location, defaults to the <tt>3d-box-center</tt> translated along the corresponding element of <tt>view-vectors</tt>) by the local camera distance. The camera distance is computed based on the field-of-view angle and the <tt>bounding-sphere</tt></li> <li><tt>:orientation</tt> (3d matrix indicating camera orientation)</li> <li><tt>field-of-view</tt> Angle in degrees of the view frustrum (i.e. lens angle of the virtual camera)." viewpoints (mapcan #'(lambda(key vector) ;; ;; FLAG -- compute this distance to do a fit ;; (let ((transform (alignment :top vector :rear (if (or (same-direction-vectors? vector *nominal-z-vector*) (same-direction-vectors? vector *nominal-z-vector-r*)) *nominal-y-vector* *nominal-z-vector*)))) (let* ((2d-box (project-3d-box (the 3d-box) vector (matrix:transpose-matrix transform))) (max-extent (max (- (get-x (second 2d-box)) (get-x (first 2d-box))) (- (get-y (second 2d-box)) (get-y (first 2d-box))))) (camera-distance (* (the camera-distance-discount) (* (+ (/ max-extent (tan (degree (the field-of-view-default)))) (getf (the bounding-sphere) :radius)) (/ (the zoom-factor-renderer))))) ) (list key (list :point (translate-along-vector (the 3d-box-center) vector camera-distance) :orientation transform :speed (div camera-distance 5) :field-of-view (the field-of-view-default)))))) (plist-keys (the view-vectors)) (plist-values (the view-vectors)))) (flight-paths (list (list :points (list (make-point 0 -100 10) (make-point 0 -90 10) (make-point 0 -80 10) (make-point 0 -70 10) (make-point 0 -60 10) (make-point 0 -50 10) (make-point 0 -40 10) (make-point 0 -30 10) (make-point 0 -20 10) (make-point 0 -10 10) (make-point 0 0 10)) :vectors (mapcar #'(lambda(vector) (alignment :top vector :rear (if (or (same-direction-vectors? vector *nominal-z-vector*) (same-direction-vectors? vector *nominal-z-vector-r*)) *nominal-y-vector* *nominal-z-vector*))) (list (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0) (make-vector 0 -1 0))) :fields-of-view (make-list 11 :initial-element 0.5)))) ("3D Point. The effective view center for the scene contained in this view object. Defaults to the center of the bounding sphere of all the objects in the scene, consisting of the <tt>object-roots</tt> and the <tt>objects</tt>." 3d-box-center (getf (the bounding-sphere) :center)) ("Plist. Keys indicate view vector names (e.g. <tt>:trimetric</tt>), and values contain the 3D vectors. Defaults to the parameter <tt>*standard-views*</tt>, but with the key corresponding to current <tt>(the view)</tt> ordered first in the plist. This list of view-vectors is used to construct the default <tt>viewpoints</tt>." view-vectors (append (list (the view) (getf *standard-views* (the view))) (mapcan #'(lambda(key val) (when (not (eql key (the view))) (list key val))) (plist-keys *standard-views*) (plist-values *standard-views*)))) ("List of two 3D points. The left-front-lower and right-rear-upper corners of the axis-aligned bounding box of the <tt>object-roots</tt> and <tt>objects</tt>." 3d-box (bounding-box-from-list (the object-roots) :local-objects (the objects))) ("Plist containing keys: <tt>:center</tt> and <tt>:radius</tt>. This plist represents the tightest-fitting sphere around all the objects listed in the <tt>object-roots</tt> and the <tt>objects</tt>" bounding-sphere (let ((ll (first (the 3d-box))) (ur (second (the 3d-box)))) (let ((x1 (get-x ll)) (y1 (get-y ll)) (z1 (get-z ll)) (x2 (get-x ur)) (y2 (get-y ur)) (z2 (get-z ur))) (let ((center (make-point (+ x1 (half (- x2 x1))) (+ y1 (half (- y2 y1))) (+ z1 (half (- z2 z1)))))) (list :center center :radius (3d-distance center ll)))))))) ;; ;; FLAG -- to utilities ;; FLAG -- see if this is used anywhere but in ;; renderer-mixin, if so, make into member function. ;; (defun project-3d-box (bbox vector transform) (let ((p1 (first bbox)) (p2 (second bbox))) (let ((2d-points (mapcar #'(lambda(point) (transform-3d-vector (inter-line-plane point vector p1 vector) transform)) (list p1 (make-point (get-x p1) (get-y p1) (get-z p2)) (make-point (get-x p1) (get-y p2) (get-z p2)) (make-point (get-x p2) (get-y p1) (get-z p1)) (make-point (get-x p2) (get-y p2) (get-z p2)) (make-point (get-x p1) (get-y p2) (get-z p1)) (make-point (get-x p2) (get-y p1) (get-z p2)) p2)))) (list (make-point (apply #'min (mapcar #'get-x 2d-points)) (apply #'min (mapcar #'get-y 2d-points))) (make-point (apply #'max (mapcar #'get-x 2d-points)) (apply #'max (mapcar #'get-y 2d-points)))))))
9,693
Common Lisp
.lisp
147
43.081633
139
0.488746
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
250b1fcff719fc56ca091168529c62dba4a679d39b3a6bbdadf4bbfdc812ef1d
35,773
[ -1 ]
35,774
presets.lisp
lisp-mirror_gendl/geom-base/prereqs/source/presets.lisp
(in-package :geom-base) ;; ;; FLAG --- need to use asdf around-compile method (or something like ;; it) to set these only temporarily. ;; (setq cl-who:*prologue* "<!doctype HTML>") (setq cl-who:*attribute-quote-char* #\") (setq cl-who:*downcase-tokens-p* nil)
265
Common Lisp
.lisp
8
31.875
69
0.694118
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2d8a0a7d64531e885f0be75c8052348bc1eba2a929ab9cbcb897caf4ca330213
35,774
[ -1 ]
35,775
3d-point-vector-data-types.lisp
lisp-mirror_gendl/geom-base/prereqs/source/3d-point-vector-data-types.lisp
(in-package :geom-base) (defun 3d-point? (point) "Boolean. A predicate function to check if a point is 3-dimensional." (3d-point-p point) ) (defun 3d-vector? (vector) "Boolean. A predicate function to check if a vector is 3-dimensional." (3d-vector-p vector) ) (deftype 3d-point () "Datatype 3d-point is the result of a make-point function using 3 coordinates (e.g., X, Y & Z), not an instance of the define-object point" '(satisfies 3d-point-p) ) (deftype 3d-vector () "Datatype 3d-vector is the result of a make-vector function using 3 coordinates." '(satisfies 3d-vector-p) ) (defun 3d-point-p (point) "Boolean. FUNCTION 3d-point-p - predicate function to check if a make-point is 3D. That is, the point has 3 dimensions, representing a 3-dimensional point. USAGE 3d-point-p point DESCRIPTION A predicate function to check if a point is 3-dimensional. The function may also be accessed by calling the function 3d-point?. EXAMPLES (3d-point-p (make-point 1 2 3)) --> t (3d-point-p (make-point 1 2 3 4)) --> nil " (and (arrayp point) (eq (array-total-size point) 3) (every #'(lambda(entry) (typep entry 'double-float)) point))) (defun 3d-vector-p (vector) "Boolean. FUNCTION 3d-vector-p - predicate function to check if a vector is 3D. That is, the vector has 3 dimensions, representing a 3-dimensional vector. USAGE 3d-vector-p vector DESCRIPTION A predicate function to check if a vector is 3-dimensional. The function may also be accessed by calling the function 3d-vector?. EXAMPLES (3d-vector-p (make-vector 1 2 3)) --> t (3d-vector-p (make-vector 1 2 3 4)) --> nil " (and (arrayp vector) (eq (array-total-size vector) 3) (every #'(lambda(entry) (typep entry 'double-float)) vector)))
1,909
Common Lisp
.lisp
57
28.701754
80
0.681167
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d31809ffbc965ce1ef70f10d92220e6f960a9b8eb8c9f4394704168abbe88199
35,775
[ -1 ]
35,776
matrix.lisp
lisp-mirror_gendl/geom-base/prereqs/source/matrix.lisp
;; ;; Code here is from CMU AI repository. ;; ;; ;; http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/math/matrix/0.html ;; ;; (eval-when (:compile-toplevel :load-toplevel :execute) (defpackage :matrix (:use :common-lisp) (:export #:matrixp #:num-rows #:num-cols #:square-matrix? #:make-matrix #:make-identity-matrix #:copy-matrix #:print-matrix #:transpose-matrix #:multiply-matrix #:add-matrix #:subtract-matrix #:invert-matrix #:solve-matrix))) (in-package :matrix) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Matrix operations ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun matrixp (matrix) "Test whether the argument is a matrix" (and (arrayp matrix) (= (array-rank matrix) 2))) (defun num-rows (matrix) "Return the number of rows of a matrix" (array-dimension matrix 0)) (defun num-cols (matrix) "Return the number of rows of a matrix" (array-dimension matrix 1)) (defun square-matrix? (matrix) "Is the matrix a square matrix?" (and (matrixp matrix) (= (num-rows matrix) (num-cols matrix)))) (defun make-matrix (rows &optional (cols rows)) "Create a matrix filled with zeros. If only one parameter is specified the matrix will be square." (make-array (list rows cols) :initial-element 0)) (defun make-identity-matrix (size) "Make an identity matrix of the specified size." (let ((matrix (make-array (list size size) :initial-element 0))) (dotimes (i size matrix) (setf (aref matrix i i) 1)))) (defun copy-matrix (matrix) "Return a copy of the matrix." (let* ((rows (num-rows matrix)) (cols (num-cols matrix)) (copy (make-array (list rows cols)))) (dotimes (row rows copy) (dotimes (col cols) (setf (aref copy row col) (aref matrix row col)))))) (defun print-matrix (matrix &optional (destination t) (control-string "~20S")) "Print a matrix. The optional control string indicates how each entry should be printed." (let ((rows (num-rows matrix)) (cols (num-cols matrix))) (dotimes (row rows) (format destination "~%") (dotimes (col cols) (format destination control-string (aref matrix row col)))) (format destination "~%"))) (defun transpose-matrix (matrix) "Transpose a matrix" (let* ((rows (num-rows matrix)) (cols (num-cols matrix)) (transpose (make-matrix cols rows))) (dotimes (row rows transpose) (dotimes (col cols) (setf (aref transpose col row) (aref matrix row col)))))) (defun multiply-matrix (&rest matrices) "Multiply matrices" (labels ((multiply-two (m1 m2) (let* ((rows1 (num-rows m1)) (cols1 (num-cols m1)) (cols2 (num-cols m2)) (result (make-matrix rows1 cols2))) (dotimes (row rows1 result) (dotimes (col cols2) (dotimes (i cols1) (setf (aref result row col) (+ (aref result row col) (* (aref m1 row i) (aref m2 i col)))))))))) (when matrices ; Empty arguments check (reduce #'multiply-two matrices)))) (defun add-matrix (&rest matrices) "Add matrices" (labels ((add-two (m1 m2) (let* ((rows (num-rows m1)) (cols (num-cols m1)) (result (make-matrix rows cols))) (dotimes (row rows result) (dotimes (col cols) (setf (aref result row col) (+ (aref m1 row col) (aref m2 row col)))))))) (when matrices ; Empty arguments check (reduce #'add-two matrices)))) (defun subtract-matrix (&rest matrices) "Subtract matrices" (labels ((subtract-two (m1 m2) (let* ((rows (num-rows m1)) (cols (num-cols m1)) (result (make-matrix rows cols))) (dotimes (row rows result) (dotimes (col cols) (setf (aref result row col) (- (aref m1 row col) (aref m2 row col)))))))) (when matrices ; Empty arguments check (reduce #'subtract-two matrices)))) (defun invert-matrix (matrix &optional (destructive nil)) "Find the inverse of a matrix. By default this operation is destructive. If you want to preserve the original matrix, call this function with an argument of NIL to destructive. changed default to NIL so it is not destructive -- DJC." (let ((result (if destructive matrix (copy-matrix matrix))) (size (num-rows matrix)) (temp 0)) (dotimes (i size result) (setf temp (aref result i i)) (dotimes (j size) (setf (aref result i j) (if (= i j) (/ (aref result i j)) (/ (aref result i j) temp)))) (dotimes (j size) (unless (= i j) (setf temp (aref result j i) (aref result j i) 0) (dotimes (k size) (setf (aref result j k) (- (aref result j k) (* temp (aref result i k)))))))))) (defun exchange-rows (matrix row-i row-j) "Exchange row-i and row-j of a matrix" (let ((cols (num-cols matrix))) (dotimes (col cols) (rotatef (aref matrix row-i col) (aref matrix row-j col))))) (defun eliminate-matrix (matrix rows cols) "Gaussian elimination with partial pivoting. " ;; Evaluated for side effect. A return value of :singular indicates the ;; matrix is singular (an error). (let ((max 0)) (loop for i below rows do (setf max i) do (loop for j from (1+ i) below rows do (when (> (abs (aref matrix j i)) (abs (aref matrix max i))) (setf max j))) do (when (zerop (aref matrix max i)) (return-from eliminate-matrix :singular)) ; error "Singular matrix" do (loop for k from i below cols ; Exchange rows do (rotatef (aref matrix i k) (aref matrix max k))) do (loop for j from (1+ i) below rows do (loop for k from (1- cols) downto i do (setf (aref matrix j k) (- (aref matrix j k) (* (aref matrix i k) (/ (aref matrix j i) (aref matrix i i))))) ))) matrix)) (defun substitute-matrix (matrix rows cols) (let ((temp 0.0) (x (make-array rows :initial-element 0))) (loop for j from (1- rows) downto 0 do (setf temp 0.0) do (loop for k from (1+ j) below rows do (incf temp (* (aref matrix j k) (aref x k)))) do (setf (aref x j) (/ (- (aref matrix j (1- cols)) temp) (aref matrix j j)))) x)) (defun solve-matrix (matrix &optional (destructive t) print-soln) "Solve a matrix using Gaussian elimination Matrix must be N by N+1 Assume solution is stored as the N+1st column of the matrix" (let ((rows (num-rows matrix)) (cols (num-cols matrix)) (result (if destructive matrix (copy-matrix matrix)))) (unless (= (1+ rows) cols) (error "Ill formed matrix")) ; Cryptic error message (cond ((eq :singular (eliminate-matrix result rows cols))) (t (let ((soln (substitute-matrix result rows cols))) (when print-soln (loop for i below rows do (format t "~% X~A = ~A" i (aref soln i)))) soln))))) (provide :matrixops)
7,967
Common Lisp
.lisp
189
32.132275
91
0.542417
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2254b2fd36fed2bc8d2af2f702fa12e8835bb183a014d708a0bdd0432dee4804
35,776
[ -1 ]
35,777
utilities.lisp
lisp-mirror_gendl/geom-base/prereqs/source/utilities.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) ;; ;; FLAG -- efficiency!!! ;; (defun array-to-3d-vector (array) "3D Vector. Returns a 3D-Vector of double-floats built from a 3-by-1 Lisp array of numbers. :arguments (array \"3-by-1 Lisp array of numbers\")" (make-vector (aref array 0 0) (aref array 0 1) (aref array 0 2))) (defun 3d-vector-to-array (vector) "3-by-1 Lisp array of double-floats. Returns a 3-by-1 Lisp array of double-float numbers built from a 3D-Vector of double-floats. This can be useful for example for multiplying a GDL 3d-point (which is a 1-d vector) by a 3x3 matrix represented as a 2D Lisp array. :arguments (vector \"3D-Vector of double-floats (e.g. created with make-vector macro)\")" (make-array (list 1 3) :initial-contents (list (list (get-x vector) (get-y vector) (get-z vector))))) ;; ;; FLAG -- handle points of 2 and 4 dimensions. ;; (defun get-x (point) "Double-float number. Returns X component of point or vector :arguments (point \"2D, 3D, or 4D point\")" (svref point 0)) (defun get-u (point) "Double-float number. Returns U component of 2D parameter value. :arguments (point \"2D point\")" (get-x point)) (defun get-v (point) "Double-float number. Returns V component of 2D parameter value. n:arguments (point \"2D point\")" (get-y point)) (defun %get-x% (point) (coerce (svref point 0) 'single-float)) (defun get-y (point) "Double-float number. Returns Y component of point or vector :arguments (point \"2D, 3D, or 4D point\")" (svref point 1)) (defun %get-y% (point) (coerce (svref point 1) 'single-float)) (defun get-z (point) "Double-float number. Returns Z component of point or vector :arguments (point \"3D or 4D point\")" (svref point 2)) (defun %get-z% (point) (coerce (svref point 2) 'single-float)) (defun get-w (quaternion) "Double-float number. Returns W component of point or vector :arguments (quaternion \"4D point, Quaternion, or Axis-Angle style rotation spec\")" (svref quaternion 3)) (defun %get-w% (point) (coerce (svref point 3) 'single-float)) (defun subtract-vectors (v1 v2) "Vector. Return a new vector, the result of affine vector subtraction. :arguments (v1 \"2D, 3D, or 4D Vector\" v2 \"2D, 3D, or 4D Vector\")" (ecase (array-dimension v1 0) (2 (make-vector (- (svref v1 0) (svref v2 0)) (- (svref v1 1) (svref v2 1)))) (3 (make-vector (- (svref v1 0) (svref v2 0)) (- (svref v1 1) (svref v2 1)) (- (svref v1 2) (svref v2 2)))) (4 (make-vector (- (svref v1 0) (svref v2 0)) (- (svref v1 1) (svref v2 1)) (- (svref v1 2) (svref v2 2)) (- (svref v1 3) (svref v2 3)))))) (defun add-vectors (v1 v2) "Vector. Return a new vector, the result of affine vector addition. :arguments (v1 \"2D, 3D, or 4D Vector\" v2 \"2D, 3D, or 4D Vector\")" (ecase (array-dimension v1 0) (2 (make-vector (+ (svref v1 0) (svref v2 0)) (+ (svref v1 1) (svref v2 1)))) (3 (make-vector (+ (svref v1 0) (svref v2 0)) (+ (svref v1 1) (svref v2 1)) (+ (svref v1 2) (svref v2 2)))) (4 (make-vector (+ (svref v1 0) (svref v2 0)) (+ (svref v1 1) (svref v2 1)) (+ (svref v1 2) (svref v2 2)) (+ (svref v1 3) (svref v2 3)))))) (defun 3d-distance (point-1 point-2) "Number. The three-dimensional distance from point-1 to point-2. :arguments (point-1 \"3D point\" point-1 \"3D point\")" (declare ;;(type (array double-float) point-1 point-2) (optimize (speed 3) (compilation-speed 0) (safety 0) (debug 0))) (cond ((and (= (array-dimension point-1 0) 3) (= (array-dimension point-2 0) 3)) (let ((dx (- (svref point-1 0) (svref point-2 0))) (dy (- (svref point-1 1) (svref point-2 1))) (dz (- (svref point-1 2) (svref point-2 2)))) (sqrt (+ (* dx dx) (* dy dy) (* dz dz))))) ((and (= (array-dimension point-1 0) 2) (= (array-dimension point-2 0) 2)) (let ((dx (- (svref point-1 0) (svref point-2 0))) (dy (- (svref point-1 1) (svref point-2 1)))) (sqrt (+ (* dx dx) (* dy dy))))) (t (error "Invalid arguments ~s and ~s passed to 3d-distance~%" point-1 point-2)))) (defun scalar*vector (scalar vector) "Vector. Returns result of multiplying the scalar number by the vector :arguments (scalar \"Number\" vector \"2D, 3D, or 4D Vector\")" (ecase (array-dimension vector 0) (2 (make-array 2 :initial-contents (list (* scalar (svref vector 0)) (* scalar (svref vector 1))))) (3 (make-array 3 :initial-contents (list (* scalar (svref vector 0)) (* scalar (svref vector 1)) (* scalar (svref vector 2))))) (4 (make-array 4 :initial-contents (list (* scalar (svref vector 0)) (* scalar (svref vector 1)) (* scalar (svref vector 2)) (* scalar (svref vector 3))))))) ;; ;; FLAG consider replacing these matrix functions with standard ones. ;; (defun scalar*matrix (scalar matrix) "Lisp Array. Returns result of multiplying the scalar number by the matrix. :arguments (scalar \"Number\" matrix \"Lisp Array of Numbers\")" (let ((n (array-dimension matrix 0)) (m (array-dimension matrix 1))) (let ((return-matrix (make-array (list n m)))) (dotimes (i n return-matrix) (dotimes (j m) (setf (aref return-matrix i j) (* (aref matrix i j) scalar))))))) (defun add-matrices (&rest matrices) "Lisp Array. Adds two matrices element-by-element. :rest (matrics \"Lisp Arrays of same dimensions\")" (let ((n (array-dimension (first matrices) 0)) (m (array-dimension (first matrices) 1))) (mapc #'(lambda(dimension rank) (when (some #'(lambda(matrix) (/= (array-dimension matrix rank) dimension)) (rest matrices)) (error "add-matrices given matrices with incompatible dimensions: ~s~%" matrices))) (list n m) (list 0 1)) (let ((return-matrix (make-array (list n m) :initial-element 0d0))) (dotimes (i n return-matrix) (dotimes (j m) (dolist (matrix matrices) (setf (aref return-matrix i j) (+ (aref return-matrix i j) (aref matrix i j))))))))) (defun matrix*vector (matrix vector) "Lisp array. Multiplies matrix by column vector of compatible dimension. :arguments (matrix \"Lisp Array of Numbers\" vector \"Vector\")" (when (not (and (= (array-rank vector) 1) (= (array-dimension matrix 1) (length vector)))) (error "matrix*vector given arguments of incompatible length: ~s and ~s~%" matrix vector)) (let ((m (array-dimension matrix 0)) (n (array-dimension matrix 1))) (let ((result-vector (if (= m 3) (make-vector 0 0 0) (make-array m :initial-element 0d0)))) (dotimes (i m result-vector) (dotimes (j n) (setf (aref result-vector i) (+ (aref result-vector i) (* (aref vector j) (aref matrix i j))))))))) (defun transpose-matrix (matrix) "Lisp array. Transposes rows and columns of <b>matrix</b>. :arguments (matrix \"Lisp Array\")" (let ((m (array-dimension matrix 0)) (n (array-dimension matrix 1))) (let ((return-matrix (make-array (list n m)))) (dotimes (i m return-matrix) (dotimes (j n return-matrix) (setf (aref return-matrix j i) (aref matrix i j))))))) (defun transform-3d-vector (vector transform) (matrix*vector (matrix:transpose-matrix transform) vector)) (defun multiply-matrices (matrix-1 matrix-2) "Lisp Array. Multiplies compatible-size matrices according to normal matrix math. :arguments (matrix-1 \"Lisp Array of Numbers\" matrix-2 \"Lisp Array of Numbers\")" (let (1d-result?) (when (= (length (array-dimensions matrix-1)) 1) (setq 1d-result? t) (setq matrix-1 (3d-vector-to-array matrix-1))) (when (= (length (array-dimensions matrix-2)) 1) (setq matrix-2 (3d-vector-to-array matrix-2))) (when (/= (array-dimension matrix-1 1) (array-dimension matrix-2 0)) (error "multiply-matrices given arguments of incompatible lengths: ~s and ~s~%" matrix-1 matrix-2)) (let ((result (let ((n (array-dimension matrix-1 0)) (k (array-dimension matrix-1 1)) (p (array-dimension matrix-2 1))) (let ((array (make-array (list n p)))) (dotimes (i n array) (dotimes (j p) (setf (aref array i j) (let ((sum 0)) (dotimes (s k sum) (setq sum (+ sum (* (aref matrix-1 i s) (aref matrix-2 s j))))))))))))) (if 1d-result? (array-to-3d-vector result) result)))) (defun dot-vectors (vector-1 vector-2) "Number. Returns the dot product of vector-1 and vector-2. :arguments (vector-1 \"2D, 3D, or 4D Vector\" vector-2 \"2D, 3D, or 4D Vector\")" (apply #'+ (mapcar #'* (coerce vector-1 'list) (coerce vector-2 'list)))) (defun rh-rule-cross (vector-1 axis-1 vector-2 axis-2) (multiple-value-bind (vector-1 axis-1) (unitize-with-axis vector-1 axis-1) (multiple-value-bind (vector-2 axis-2) (unitize-with-axis vector-2 axis-2) (let ((nominal (cross-vectors vector-1 vector-2)) (axes (list :right :rear :top :right))) (let ((reverse? (not (eql (nth (1+ (position axis-1 axes)) axes) axis-2)))) (if reverse? (reverse-vector nominal) nominal)))))) (defun alignment (axis1 vector1 &optional (axis2 (if (member axis1 (list :top :bottom)) :rear :top)) (vector2 (case axis2 (:rear (if (or (same-direction-vectors? vector1 (make-vector 0 1 0)) (same-direction-vectors? vector1 (make-vector 0 -1 0))) (make-vector 0 0 1) (make-vector 0 1 0))) (:top (if (or (same-direction-vectors? vector1 (make-vector 0 0 1)) (same-direction-vectors? vector1 (make-vector 0 0 -1))) (make-vector 0 1 0) (make-vector 0 0 1))))) (axis3 (first (set-difference (list :right :rear :top) (mapcar #'normalize-axis (list axis1 axis2))))) (vector3 (unitize-vector (rh-rule-cross (orthogonal-component vector2 vector1) axis2 vector1 axis1)))) "3x3 Orthonormal Rotation Matrix. Constructs a rotation matrix from the given axes and vectors. Up to three pairs of axis and vector can be given. If only one pair is given, then the orthogonal component of its vector with respect to the other two global axes is used. If a second pair is given, then the orthogonal component of its vector with respect to the first vector is used. A third pair is only required if a left-handed coordinate system is desired (right-handed is the default). The third vector will always be converted to the cross of the first two, unless it is given as the reverse of this, which will force a left-handed coordinate system. Axes are direction keywords which can be one of: <ul><li><tt>:right</tt></li> <li><tt>:left</tt></li> <li><tt>:rear</tt></li> <li><tt>:front</tt></li> <li><tt>:top</tt></li> <li><tt>:bottom</tt></li></ul> The second axis keyword, if given, must be orthogonal to the first, and the third, if given, must be orthogonal to the first two. :arguments (axis-1 \"Direction Keyword\" vector1 \"3D Vector\") :&optional (axis-2 \"Direction Keyword\" vector2 \"3D Vector\" axis-3 \"Direction Keyword\" vector3 \"3D Vector\")" (multiple-value-bind (vector-1 axis-1) (unitize-with-axis vector1 axis1) (multiple-value-bind (vector-2 axis-2) (unitize-with-axis vector2 axis2) (setq vector-2 (unitize-vector (orthogonal-component vector-2 vector-1))) (multiple-value-bind (vector-3 axis-3) (unitize-with-axis vector3 axis3) (let ((vector-3-nominal (unitize-vector (rh-rule-cross vector-1 axis-1 vector-2 axis-2)))) (setq vector-3 (if (> (angle-between-vectors vector-3 vector-3-nominal) pi/2) (reverse-vector vector-3-nominal) vector-3-nominal)) (let ((vector-axis-list (list axis-1 vector-1 axis-2 vector-2 axis-3 vector-3))) (make-transform (list (coerce (getf vector-axis-list :right) 'list) (coerce (getf vector-axis-list :rear) 'list) (coerce (getf vector-axis-list :top) 'list))))))))) (defun normalize-color (triplet &key (tolerance 0.1)) (if (every #'(lambda(num)(< num tolerance)) triplet) (list 1 1 1) triplet)) (defun normalize-axis (axis) (ecase axis ((:left :right) :right) ((:top :bottom) :top) ((:front :rear) :rear))) (defun unitize-with-axis (vector axis) (ecase axis ((:right :rear :top) (values (unitize-vector vector) axis)) ((:left :front :bottom) (values (unitize-vector (reverse-vector vector)) (ecase axis (:left :right) (:front :rear) (:bottom :top)))))) (defun make-transform (list-of-lists) "Lisp array. Builds a matrix from <b>list-of lists</b>. :arguments (list-of-lists \"List of lists of numbers\")" (make-array (list (length list-of-lists) (length (first list-of-lists))) :initial-contents (mapcar #'(lambda(outer) (mapcar #'(lambda(inner) (coerce inner 'double-float)) outer)) list-of-lists))) (defparameter *print-deprecated-warnings?* nil) (defun angle-between-vectors-d (vector-1 vector-2 &optional reference-vector &rest args) "Number. This function is identical to angle-between-vectors, but returns the angle in degrees. Refer to angle-between-vectors for more information. Technical note: the <b>more</b> argument has been introduced to support both angle-between-vectors call conventions and the legacy signature: (vector-1 vector-2 &optional reference-vector negative?) Optionally, a deprecation warning is printed when code invokes this legacy pattern.." ;; resolve &rest arguments. (let ((arglist (let ((length (length args))) (cond ((= length 1) ;; legacy signature: ;; (vector-1 vector-2 &optional reference-vector negative?) (when *print-deprecated-warnings?* (warn "negative? argument for angle-between-vectors-d is deprecated. Use :-ve instead.")) (list vector-1 vector-2 reference-vector :-ve (first args))) ((evenp length) ;; angle-between-vectors signature: ;; (vector-1 vector-2 &optional reference-vector &key (epsilon *zero-epsilon*) -ve) (nconc (list vector-1 vector-2 reference-vector) args)) (t ;; not allowed. (error (format nil "angle-between-vectors-d received invalid arguments: ~a" (nconc (list vector-1 vector-2 reference-vector) args)))))))) (radians-to-degrees (apply #'angle-between-vectors arglist)) )) #+nil (defun angle-between-vectors-d (vector-1 vector-2 &optional reference-vector negative?) "Number. Returns the angle in degrees between <tt>vector-1</tt> and <tt>vector-2</tt>. If no <tt>reference-vector</tt> is given, the smallest possible angle is returned. If a <tt>reference-vector</tt> is given, computes according to the right-hand rule. If <tt>negative?</tt> is specified as non-NIL, returns a negative number for angle if it really is negative according to the right-hand rule. :arguments (vector-1 \"3D Vector\" vector-2 \"3D Vector\") :&optional ((reference-vector NIL) \"3D Vector\" (negative? nil) \"Boolean\")" (if reference-vector (let ((angle (radians-to-degrees (angle-between-vectors vector-1 vector-2 reference-vector)))) (if negative? (if (> angle 180) (- angle 360) angle) angle)) (radians-to-degrees (angle-between-vectors vector-1 vector-2)))) (defun angle-between-vectors (vector-1 vector-2 &optional reference-vector &key (epsilon *zero-epsilon*) -ve negative?) "Number. Returns the angle in radians between <b>vector-1</b> and <b>vector-2</b>. If no <b>reference-vector</b> given, the smallest possible angle is returned. If a <b>reference-vector</b> is given, computes according to the right-hand rule. If <b>-ve</b> is given, returns a negative number for angle if it really is negative according to the right-hand rule. :arguments (vector-1 \"3D Vector\" vector-2 \"3D Vector\") :&optional ((reference-vector nil) \"3D Vector\") :&key ((epsilon *zero-epsilon*) \"Number. Determines how small of an angle is considered to be zero.\" (-ve nil) \"Boolean\")" (let ((vector-1 (unitize-vector vector-1 :epsilon epsilon)) (vector-2 (unitize-vector vector-2 :epsilon epsilon))) (let ((dot-vector (dot-vectors vector-1 vector-2))) (when (> dot-vector 1.0) (setq dot-vector 1.0)) (when (< dot-vector -1.0) (setq dot-vector -1.0)) (let ((smallest-angle (acos dot-vector))) (when (< smallest-angle epsilon) (setq smallest-angle 0.0)) (let ((try (if (and reference-vector (minusp (dot-vectors reference-vector (cross-vectors vector-1 vector-2)))) (- (twice pi) smallest-angle) smallest-angle))) (if (and (or -ve negative?) (> try pi)) (- try (twice pi)) try)))))) #+nil (defun angle-between-vectors (vector-1 vector-2 &optional reference-vector &key (epsilon *zero-epsilon*) -ve negative?) "Number. Returns the angle in radians between <b>vector-1</b> and <b>vector-2</b>. If no <b>reference-vector</b> given, the smallest possible angle is returned. If a <b>reference-vector</b> is given, computes according to the right-hand rule. If <b>:-ve t</b> or <b>:negative? t</b> is given, returns a negative number for angle if it really is negative according to the right-hand rule. :arguments (vector-1 \"3D Vector\" vector-2 \"3D Vector\") :&optional ((reference-vector nil) \"3D Vector\") :&key ((epsilon *zero-epsilon*) \"Number. Determines how small of an angle is considered to be zero.\" (-ve nil) \"Boolean\" (negative? nil) \"Boolean (synonym to -ve)\")" (let ((vector-1 (unitize-vector vector-1)) (vector-2 (unitize-vector vector-2))) (let ((dot-vector (dot-vectors vector-1 vector-2))) (when (> dot-vector 1.0d0) (setq dot-vector 1.0d0)) (when (< dot-vector -1.0d0) (setq dot-vector -1.0d0)) (let ((smallest-angle (acos dot-vector))) (when (< smallest-angle epsilon) (setq smallest-angle 0.0d0)) (let ((try (if (and reference-vector (minusp (dot-vectors reference-vector (cross-vectors vector-1 vector-2)))) (- (twice pi) smallest-angle) smallest-angle))) (if (and (or -ve negative?) (> try pi)) (- try (twice pi)) try)))))) (defun unitize-vector (vector &key (epsilon *zero-epsilon*)) "Unit Vector. Returns the normalized unit-length vector corresponding to <b>vector</b>. :arguments (vector \"3D Vector\") :&key ((espsilon *zero-epsilon*) \"Number. How close vector should be to 1.0 to be considered unit-length.\")" (when (and *zero-vector-checking?* (zero-vector? vector)) (error "~s has Euclidean length zero; cannot unitize." vector)) (if (near-to? (length-vector vector) 1.0 epsilon) vector (scalar*vector (/ (length-vector vector)) vector))) #+nil (defun unitize-vector (vector) "Unit Vector. Returns the normalized unit-length vector corresponding to <b>vector</b>. :arguments (vector \"3D Vector\")" (when (and *zero-vector-checking?* (zero-vector? vector)) (error "~s has Euclidean length zero; cannot unitize." vector)) (if (near-to? (length-vector vector) 1.0) vector (scalar*vector (/ (length-vector vector)) vector))) (defun orthogonal-component (vector reference-vector) "3D Unit Vector. Returns the unit vector orthogonal to <b>reference-vector</b> which is as close as possible to <b>vector</b>. :arguments (vector \"3D Vector\" reference-vector \"3D Vector\")" (unitize-vector (if (zerop (dot-vectors vector reference-vector)) vector (let ((normal (cross-vectors vector reference-vector))) (if (zero-vector? normal) +nominal-origin+ (cross-vectors reference-vector normal)))))) (defun parallel-vectors? (vector-1 vector-2 &key (tolerance *zero-epsilon*) directed?) "Boolean. Returns non-nil iff <b>vector-1</b> and <b>vector-2</b> are pointing in the same direction or opposite directions. :arguments (vector-1 \"3D Vector\" vector-2 \"3D Vector\") :&key ((tolerance *zero-epsilon*) \"Number\" (directed? nil) \"Boolean. If :directed? is t, the function returns t if the vectors are both parallel and point in the same direction. The default is nil, meaning that the function will return t regardless of which way the vectors point, as long as they are parallel.\")" (or (same-direction-vectors? vector-1 vector-2 :tolerance tolerance) (unless directed? (same-direction-vectors? vector-1 (reverse-vector vector-2) :tolerance tolerance)))) (defun same-direction-vectors? (vector-1 vector-2 &key (tolerance *zero-epsilon*)) "Boolean. Returns non-NIL iff <b>vector-1</b> and <b>vector-2</b> are pointing in the same direction. :arguments (vector-1 \"3D Vector\" vector-2 \"3D Vector\") :&key ((tolerance *zero-epsilon*) \"Number\")" (and (not (or (zero-vector? vector-1) (zero-vector? vector-2))) (coincident-point? (unitize-vector vector-1) (unitize-vector vector-2) :tolerance tolerance))) (defun reverse-vector (vector) "Vector. Return the vector pointing in the opposite direction. :arguments (vector \"2D, 3D, or 4D Vector\")" (scalar*vector -1d0 vector)) (defun cross-vectors (vector-1 vector-2) "3D Vector. Returns the cross product of vector-1 and vector-2. According to the definition of cross product, this resultant vector should be orthogonal to both <b>vector-1</b> and <b>vector-2</b>. :arguments (vector-1 \"3D Vector\" vector-2 \"3D Vector\")" (make-array 3 :initial-contents (list (- (* (get-y vector-1) (get-z vector-2)) (* (get-y vector-2) (get-z vector-1))) (- (* (get-x vector-2) (get-z vector-1)) (* (get-x vector-1) (get-z vector-2))) (- (* (get-x vector-1) (get-y vector-2)) (* (get-x vector-2) (get-y vector-1)))))) (defun length-vector (vector) "Number. Return the vector's magnitude :arguments (vector \"3D Vector\")" (3d-distance (if (= (array-dimension vector 0) 3) vector (make-vector (get-x vector) (get-y vector) 0)) +nominal-origin+)) (defun zero-vector? (vector) "Boolean. Returns non-NIL iff the vector has zero length according to Common Lisp <tt>zerop</tt> function. :arguments (vector \"3D Vector\")" (and (zerop (svref vector 0)) (zerop (svref vector 1)) (zerop (svref vector 2)))) (defun degree (degrees &optional (minutes 0) (seconds 0)) "Number. Converts angle in degrees, minutes, and seconds into radians. :arguments (degrees \"Number\") :&optional ((minutes 0) \"Number\") (seconds 0) \"Number\"))" (* (/ (+ degrees (/ minutes 60) (/ seconds 3600)) 180) pi)) ;; FLAG -- this does not seem to be giving the precision one would ;; like. we probably have to start declaring some types to be ;; double-float. ;; (defun radians-to-degrees (radians) "Number. Converts angle in radians to degrees. :arguments (radians \"Number\")" (* radians (/ 180 pi))) (defun radians-to-grads (radians) "Number. Converts angle in radians to grads. :arguments (radians \"Number\")" (* (radians-to-degrees radians) (/ 10 9))) (defun rotate-vector-d (vector degrees normal) "Number. Rotates <b>vector</b> around <b>normal</b> by an amount of rotation specified by <b>degrees</b>. :arguments (vector \"3D Vector\" degrees \"Number\" normal \"3D Vector\")" (rotate-vector vector (degree degrees) normal)) (defun translate-along-vector (point vector distance &optional unit?) "3D Point. Returns a new point which is <b>point</b> translated along <b>vector</b> by <b>distance</b> :arguments (point \"3D Point\" vector \"3D Vector\" distance \"Number\")" (add-vectors point (scalar*vector distance (if unit? vector (unitize-vector vector))))) ;; ;; FLAG -- figure out how to access documentations for methods ;; e.g. for following three. ;; (defmethod direction-vector ((line list)) "3D Vector. Gives the direction of <b>line</b>, which is a line segment represented in the form of a list of two 3D Points. :arguments (line \"list of two 3D Points.\")" (subtract-vectors (second line) (first line))) (defmethod line-length ((line list)) "Number. Gives the length of <b>line</b>, which is a line segment represented in the form of a list of two 3D Points. :arguments (line \"list of two 3D Points.\")" (3d-distance (first line) (second line))) (defmethod mid-point ((line list)) "3D Point. Gives the midpoint of <b>line</b>, which is a line segment represented in the form of a list of two 3D Points. :arguments (line \"list of two 3D Points.\")" (translate-along-vector (first line) (direction-vector line) (half (line-length line)))) (defun array-to-list (array &optional (decimal-places 2)) "List. Converts <b>array</b> to a list. :arguments (array \"Lisp Array of Numbers\") :&optional ((decimal-places 2) \"Integer. Numbers will be rounded to this many decimal places.\")" (if array (if (or (> (length array) 3) (not (numberp (elt array 0)))) (coerce array 'list) (remove nil (list (number-round (get-x array) decimal-places) (number-round (get-y array) decimal-places) (if (get-z array) (number-round (get-z array) decimal-places))))))) (defun coincident-point? (point-1 point-2 &key (rank (length point-1)) (tolerance *zero-epsilon*)) "Boolean. Returns non-NIL iff the distance between <b>point-1</b> and <b>point-2</b> is less than <b>tolerance</b>. :arguments (point-1 \"3D Point\" point-2 \"3D Point\") :&key ((tolerance *zero-epsilon*) \"Number\")" (if (< rank (max (length point-1) (length point-2))) (let ((result t)) (dotimes (n rank result) (when (not (< (abs (- (svref point-1 n) (svref point-2 n))) tolerance)) (setq result nil)))) (< (3d-distance point-1 point-2) tolerance))) (defun projected-vector (vector plane-normal) "3D Vector. Returns result of projecting <b>vector</b> onto the plane whose normal is <b>plane-normal</b>. :arguments (vector \"3D Vector\" plane-normal \"3D Vector\")" (subtract-vectors vector (scalar*vector (dot-vectors vector (unitize-vector plane-normal)) (unitize-vector plane-normal)))) (defun rotate-point-d (point center normal &key arc-length angle) "3D Point. Returns the 3D Point resulting from rotating <b>point</b> about <b>center</b> in the plane defined by <b>normal</b>. The rotation can specified either by an arc length (<b>arc-length</b>) or an angle in degrees (<b>angle</b>). A second value is returned, which is the resulting angle of rotation in degrees (this is of possible use if <b>arc-length</b> is used to specify the rotation). :arguments (point \"3D Point\" center \"3D Point\" normal \"3D Vector\") :&key ((arc-length nil) \"Number\" (angle nil) \"Number\")" (if (coincident-point? point center) point (let* ((radius (3d-distance point center)) (alpha (if angle angle (div (* arc-length 180) (* pi radius)))) (vec (rotate-vector-d (subtract-vectors point center) alpha normal))) (values (translate-along-vector center vec radius) alpha)))) (defun rotate-point (point center normal &key (arc-length nil) (angle nil)) "3D Point. Returns the 3D Point resulting from rotating <b>point</b> about <b>center</b> in the plane defined by <b>normal</b>. The rotation can specified either by an arc length (<b>arc-length</b>) or an angle in radians (<b>angle</b>). A second value is returned, which is the resulting angle of rotation in radians (this is of possible use if <b>arc-length</b> is used to specify the rotation). :arguments (point \"3D Point\" center \"3D Point\" normal \"3D Vector\") :&key ((arc-length nil) \"Number\" (angle nil) \"Number\")" (if (coincident-point? point center) point (let* ((radius (3d-distance point center)) (alpha (if angle angle (/ (* arc-length pi) (* pi radius)))) (vec (rotate-vector (subtract-vectors point center) alpha normal))) (values (translate-along-vector center vec radius) alpha)))) ;; ;; Uses Rodrigues' Rotation Formula. ;; (defun rotate-vector (vector angle normal) "Number. Rotates <b>vector</b> around <b>normal</b> by an amount of rotation specified by <b>angle</b>, which is an angle measured in radians. :arguments (vector \"3D Vector\" angle \"Number\" normal \"3D Vector\")" (let* ((normal (unitize-vector normal)) (w1 (svref normal 0)) (w2 (svref normal 1)) (w3 (svref normal 2)) (w-matrix (let ((array (make-array (list 3 3) :initial-element 0d0))) (setf (aref array 0 1) (- w3) (aref array 0 2) w2 (aref array 1 0) w3 (aref array 1 2) (- w1) (aref array 2 0) (- w2) (aref array 2 1) w1) array)) (w-squared (matrix:multiply-matrix w-matrix w-matrix))) (let ((transform (matrix:add-matrix +identity-3x3+ (scalar*matrix (sin angle) w-matrix) (scalar*matrix (- 1 (cos angle)) w-squared)))) (matrix*vector transform vector)))) (defun inter-circle-sphere (circle-center circle-radius circle-plane-normal sphere-center sphere-radius positive-angle? &key (tolerance *zero-epsilon*)) "3D Point or NIL. Returns point of intersection between the circle described by <b>circle-center</b>, <b>circle-radius</b>, and <b>circle-plane-normal</b>, and the sphere described by <b>sphere-center</b> and <b>sphere-radius</b>. Iff the circle and sphere do not intersect at all, NIL is returned. :arguments (circle-center \"3D Point\" circle-radius \"Number\" circle-plane-normal \"3D Vector\" sphere-center \"3D Point\" sphere-radius \"Number\" positive-angle? \"Boolean. Controls which of two intersection points is returned\") :&key ((tolerance *zero-epsilon*) \"Controls how close the entities must come to touching to be considered as intersecting.\")" (let* ((vector-1 circle-plane-normal) (sphere-circle-center (inter-line-plane sphere-center circle-plane-normal circle-center circle-plane-normal)) (vector-2 (subtract-vectors circle-center sphere-circle-center)) (sphere-circle-radius (3d-distance sphere-circle-center (inter-line-sphere sphere-circle-center vector-2 sphere-center sphere-radius vector-2))) (transform (alignment :top vector-1 :rear (if (or (same-direction-vectors? vector-1 *nominal-z-vector*) (same-direction-vectors? vector-1 *nominal-z-vector-r*)) *nominal-y-vector* *nominal-z-vector*))) (inverse (cond ((same-direction-vectors? vector-1 *nominal-z-vector*) #2A((1.0d0 0.0d0 0.0d0) (0.0d0 1.0d0 0.0d0) (0.0d0 0.0d0 1.0d0))) ((same-direction-vectors? vector-1 *nominal-z-vector-r*) #2A((1.0d0 0.0d0 0.0d0) (0.0d0 -1.0d0 0.0d0) (0.0d0 0.0d0 1.0d0))) ((same-direction-vectors? vector-1 *nominal-x-vector*) #2a((0.0d0 0.0d0 1.0d0) (1.0d0 0.0d0 0.0d0)(0.0d0 1.0d0 0.0d0))) ((same-direction-vectors? vector-1 *nominal-x-vector-r*) #2a((0.0d0 0.0d0 1.0d0) (-1.0d0 0.0d0 0.0d0)(0.0d0 1.0d0 0.0d0))) ((same-direction-vectors? vector-1 *nominal-y-vector*) #2A((-1.0d0 0.0d0 0.0d0) (0.0d0 0.0d0 1.0d0)(0.0d0 1.0d0 0.0d0))) ((same-direction-vectors? vector-1 *nominal-y-vector-r*) #2A((1.0d0 0.0d0 0.0d0)(0.0d0 0.0d0 1.0d0) (0.0d0 1.0d0 0.0d0))) (t (matrix:transpose-matrix transform)))) (sphere-circle-center-n (array-to-3d-vector (multiply-matrices (3d-vector-to-array sphere-circle-center) inverse))) (circle-center-n (array-to-3d-vector (multiply-matrices (3d-vector-to-array circle-center) inverse)))) (let ((intersect (inter-circle-circle circle-center-n circle-radius sphere-circle-center-n sphere-circle-radius positive-angle? :tolerance tolerance))) (when intersect (array-to-3d-vector (multiply-matrices (3d-vector-to-array intersect) transform)))))) (defun inter-circle-circle (center-1 radius-1 center-2 radius-2 positive-angle? &key (tolerance *zero-epsilon*)) (let ((span (3d-distance center-1 center-2))) (cond ((coincident-point? center-1 center-2) (when (near-to? radius-1 radius-2 tolerance) :infinity)) ((> span (+ radius-1 radius-2)) nil) ((= span (+ radius-1 radius-2)) (translate-along-vector center-1 (subtract-vectors center-2 center-1) radius-1)) (t (let ((h-squared (- (^2 radius-1) (^2 (/ (+ (^2 span) (^2 radius-1) (- (^2 radius-2))) (twice span)))))) (unless (minusp h-squared) (let ((L1 (half (+ (/ (- (^2 radius-1) (^2 radius-2)) span) span))) (h (sqrt h-squared))) (let ((c1c2 (subtract-vectors center-2 center-1)) (top (make-vector 0 0 1))) (translate-along-vector (translate-along-vector center-1 c1c2 L1) (cross-vectors top (if positive-angle? c1c2 (reverse-vector c1c2))) h))))))))) ;; ;; Formula from http://astronomy.swin.edu.au/pbourke/geometry/sphereline/ ;; (defun inter-line-sphere (p-line u-line center radius side-vector) "3D Point or NIL. Returns one point of intersection between line described by point <b>p-line</b> and direction-vector <b>u-line</b>, and sphere described by <b>center</b> and <b>radius</b>. Iff the line and sphere do not intersect at all, NIL is returned. :arguments (p-line \"3D Point. Any point on the line.\" u-line \"3D Vector. Direction of the line.\" center \"3D Point. Center of the sphere.\" radius \"Number. The radius of the sphere.\" side-vector \"3D Vector. Controls which of two possible intersection points is returned.\")" (let ((p-line-2 (translate-along-vector p-line u-line (length-vector u-line)))) (let ((x1 (get-x p-line))(y1 (get-y p-line))(z1 (get-z p-line)) (x2 (get-x p-line-2))(y2 (get-y p-line-2))(z2 (get-z p-line-2)) (x3 (get-x center)) (y3 (get-y center)) (z3 (get-z center))) (let ((dx (- x2 x1)) (dy (- y2 y1)) (dz (- z2 z1))) (let ((a (+ (^2 dx) (^2 dy) (^2 dz))) (b (twice (+ (* dx (- x1 x3)) (* dy (- y1 y3)) (* dz (- z1 z3))))) (c (- (+ (^2 x3) (^2 y3) (^2 z3) (^2 x1) (^2 y1) (^2 z1)) (twice (+ (* x3 x1) (* y3 y1) (* z3 z1))) (^2 radius)))) (let ((key-val (- (^2 b) (* 4 a c)))) (cond ((zerop key-val) (let ((u (- (/ b (* 2 a))))) (make-vector (+ x1 (* dx u)) (+ y1 (* dy u)) (+ z1 (* dz u))))) ((plusp key-val) (let ((positive-u (/ (- (sqrt key-val) b) (* 2 a))) (negative-u (/ (- (- b) (sqrt key-val)) (* 2 a)))) (let ((positive-answer (make-vector (+ x1 (* dx positive-u)) (+ y1 (* dy positive-u)) (+ z1 (* dz positive-u)))) (negative-answer (make-vector (+ x1 (* dx negative-u)) (+ y1 (* dy negative-u)) (+ z1 (* dz negative-u))))) (if (coincident-point? positive-answer negative-answer) positive-answer (let ((solutions-vector (subtract-vectors positive-answer negative-answer))) (if (< (angle-between-vectors-d solutions-vector side-vector) 90) positive-answer negative-answer))))))))))))) (defun inter-line-plane (p-line u-line p-plane u-plane) "3D Point or NIL. Returns one point of intersection between line described by point <b>p-line</b> and direction-vector <b>u-line</b>, and plane described by <b>p-plane</b> and <b>u-plane</b>. Iff the line and plane do not intersect at all (i.e. they are parallel), NIL is returned. :arguments (p-line \"3D Point. Any point on the line.\" u-line \"3D Vector. Direction of the line.\" p-plane \"3D Point. Any point on the plane.\" u-plane \"3D Vector. Normal of the plane.\")" (when (not (zerop (dot-vectors u-line u-plane))) (let ((w (subtract-vectors p-line p-plane)) (n (unitize-vector u-line)) (u (unitize-vector u-plane))) (let ((s (/ (- (dot-vectors u w)) (dot-vectors u n)))) (translate-along-vector p-line n s))))) (defun inter-line-line (p-line-1 u-line-1 p-line-2 u-line-2) (inter-line-plane p-line-1 u-line-1 p-line-2 (cross-vectors (cross-vectors u-line-1 u-line-2) u-line-2))) (defmacro translate (origin &rest offsets) "[Macro] 3D Point. Within the context of a GDL object definition (i.e. a <tt>define-object</tt>), translate <b>origin</b> by any number of <b>offsets</b>. :arguments (origin \"3D Point\") :&rest (offsets \"Plist consisting of direction keywords and numbers. A direction keyword can be one of: <ul><li><tt>:top</tt> (or <tt>:up</tt>)</li> <li><tt>:bottom</tt> (or <tt>:down</tt>)</li> <li><tt>:left</tt></li> <li><tt>:right</tt></li> <li><tt>:front</tt></li> <li><tt>:rear</tt> (or <tt>:back</tt>)</li></ul>\")" (if (null offsets) origin `(translate (translate-along-vector ,origin (the (:face-normal-vector (ecase ,(first offsets) ((:up :top) :top) ((:down :bottom) :bottom) (:left :left) (:right :right) (:front :front) ((:rear :back) :rear)))) ,(second offsets)) ,@(rest (rest offsets))))) (defun create-obliqueness (v1 name-v1 v2 name-v2 self) "3x3 Orthonormal Rotation Matrix. Gives the transform required to be applied to the parent's orientation to achieve alignment indicated by the arguments. The direction keywords are the same as those used with the GDL <tt>alignment</tt> function. :arguments (vector-1 \"3D Vector\" direction-1 \"Direction Keyword\" vector-2 \"3D Vector\" direction-2 \"Direction Keyword\" self \"GDL object inheriting from <tt>base-object</tt>\")" (let* ((parent (the-object self parent)) (parent-transform (when parent (the-object parent orientation))) (inverse (when parent-transform (matrix:transpose-matrix parent-transform))) (alignment (alignment name-v1 v1 name-v2 v2))) (if inverse (matrix:multiply-matrix alignment inverse) alignment))) (defun proj-point-on-line (3d-point line-point vector) "3D-Point. Drops <b>3d-point</b> onto line containing <b>line-point</b> and whose direction-vector is <b>vector</b>. :arguments (3D-point \"3D Point\" Line-point \"3D Point\" vector \"3D Unit Vector\")" (inter-line-plane line-point vector 3d-point vector)) (defun pythagorize (&rest numbers) "Number. Returns the square root of the sum of the squares of <i>numbers</i>. :&rest (numbers \"List of Numbers\")" (sqrt (apply #'+ (mapcar #'^2 numbers)))) (defmacro roll (axis angle &rest other-axes-and-angles) "[macro] Transformation matrix. In the context of a GDL object definition (i.e. in a <tt>define-object</tt>), returns a transformation matrix based on rotation about <b>axis</b> by some <b>angle</b>. <b>Axis</b> is a keyword symbol, one of: <ul><li><tt>:lateral</tt></li> <li><tt>:longitudinal</tt></li> <li><tt>:vertical</tt></li></ul> <b>Angle</b> is specified in radians. Any number of axis-angle pairs can be specified. :arguments (axis \"Keyword Symbol\" angle \"Number\") :&rest (other-axes-and-angles \"Plist made from axis keyword symbols and numbers\")" (if other-axes-and-angles `(multiply-matrices (rotation (the (:axis-vector ,axis)) ,angle) (roll ,@other-axes-and-angles)) `(rotation (the (:axis-vector ,axis)) ,angle))) (defun rotation (vector angle) "3x3 orthonormal rotation matrix (as a Lisp Array of Numbers). Returns a transformation matrix based on a rotation by <b>angle</b>, specified in radians, about an arbitrary <b>vector</b>. :arguments (vector \"3D Vector\" angle \"Number\")" (let* ((vector (unitize-vector vector)) (w1 (get-x vector)) (w2 (get-y vector)) (w3 (get-z vector)) (w-matrix (make-array (list 3 3) :initial-contents `((0d0 ,(- w3) ,w2) (,w3 0d0 ,(- w1)) (,(- w2) ,w1 0d0)))) (w-squared (multiply-matrices w-matrix w-matrix))) (add-matrices +identity-3x3+ (scalar*matrix (sin (- angle)) w-matrix) (scalar*matrix (- 1 (cos (- angle))) w-squared)))) (defun transform-and-translate-point (vector transform trans-vector) "3D-Point. Returns the product of <b>vector</b> and <b>transform</b>, translated by (i.e. added to) <i>trans-vector</i>. :arguments (vector \"3D Vector\" transform \"3x3 Rotation Matrix\" trans-vector \"3D Vector\") :examples <pre> \(let ((transform (make-transform '((0.0 0.0 1.0) (0.0 1.0 0.0) (1.0 0.0 0.0)))) (v (make-vector 1.0 2.0 3.0)) (t-v (make-vector 3.0 0.0 0.0))) (transform-and-translate-point v transform t-v)) ---> #(6.0 2.0 1.0) </pre>" (add-vectors (transform-numeric-point vector transform) trans-vector)) (defun transform-numeric-point (vector transform) "3D-Point. Returns the product of <b>vector</b> and <i>transform</i>. :arguments (vector \"3D Vector\" transform \"3x3 Rotation Matrix\") :examples <pre> \(let ((transform (make-transform '((0.0 0.0 1.0) (1.0 0.0 0.0) (0.0 1.0 0.0)))) (v (make-vector 1.0 2.0 3.0))) (transform-numeric-point v transform)) ---> #(2.0 3.0 1.0) </pre>" (let* ((array (multiply-matrices (make-array (list 1 (length vector)) :initial-contents (list vector)) transform))) (make-vector (aref array 0 0) (aref array 0 1) (aref array 0 2)))) (defun mat (matrix index) (ecase index (0 (aref matrix 0 0)) (1 (aref matrix 0 1)) (2 (aref matrix 0 2)) (4 (aref matrix 1 0)) (5 (aref matrix 1 1)) (6 (aref matrix 1 2)) (8 (aref matrix 2 0)) (9 (aref matrix 2 1)) (10 (aref matrix 2 2)))) (defun normalize-quaternion (quaternion) (let ((factor (sqrt (+ (^2 (get-x quaternion)) (^2 (get-y quaternion)) (^2 (get-z quaternion)) (^2 (get-w quaternion)))))) (make-vector (/ (get-x quaternion) factor) (/ (get-y quaternion) factor) (/ (get-z quaternion) factor) (/ (get-w quaternion) factor)))) (defun quaternion-to-rotation (quaternion) "Euler rotation represented as a 4D Vector. Transforms <b>quaternion</b> into a Euler angle rotation consisting of an arbitrary axis and an angle of rotation about that axis. :arguments (quaternion \"Quaternion, represented as a 4D Vector\")" (when (and quaternion (not (and (zerop (get-x quaternion)) (zerop (get-y quaternion)) (zerop (get-z quaternion))))) (setq quaternion (normalize-quaternion quaternion)) (let* ((qw (get-w quaternion)) (qx (get-x quaternion)) (qy (get-y quaternion)) (qz (get-z quaternion)) (cos-angle qw) (angle (twice (acos qw))) (sin-angle (sqrt (- 1.0 (* cos-angle cos-angle))))) (when (zerop sin-angle) (setq sin-angle 1)) (let* ((vector (unitize-vector (make-vector (/ qx sin-angle)(/ qy sin-angle)(/ qz sin-angle)))) (qx (get-x vector)) (qy (get-y vector)) (qz (get-z vector))) (make-vector qx qy qz angle))))) (defun quaternion-to-matrix (quaternion) "3x3 Orthonormal Rotation Matrix. Transforms <b>quaternion</b> into a 3x3 rotation matrix. :arguments (quaternion \"Quaternion, represented as a 4D Vector\")" (let ((x (get-x quaternion)) (y (get-y quaternion)) (z (get-z quaternion)) (w (get-w quaternion))) (let ((xx (^2 x)) (xy (* x y)) (xz (* x z)) (xw (* x w)) (yy (^2 y)) (yz (* y z)) (yw (* y w)) (zz (^2 z)) (zw (* z w))) (make-array (list 3 3) :initial-contents (list (list (- 1 (twice (+ yy zz))) (twice (- xy zw)) (twice (+ xz yw))) (list (twice (+ xy zw)) (- 1 (twice (+ xx zz))) (twice (- yz xw))) (list (twice (- xz yw)) (twice (+ yz xw)) (- 1 (twice (+ xx yy))))))))) (defun determinant (3x3-matrix) (let ((mat 3x3-matrix)) (+ (* (aref mat 0 0) (aref mat 1 1) (aref mat 2 2)) (- (* (aref mat 0 0) (aref mat 1 2) (aref mat 2 1))) (- (* (aref mat 0 1) (aref mat 1 0) (aref mat 2 2))) (* (aref mat 0 1) (aref mat 1 2) (aref mat 2 0)) (* (aref mat 0 2) (aref mat 1 0) (aref mat 2 1)) (- (* (aref mat 0 2) (aref mat 1 1) (aref mat 2 0)))))) (defun make-quaternion (qx qy qz qw) (let ((q (make-array 4 :element-type 'double-float))) (setf (aref q 0) (coerce qx 'double-float) (aref q 1) (coerce qy 'double-float) (aref q 2) (coerce qz 'double-float) (aref q 3) (coerce qw 'double-float)) q)) (defun matrix-to-quaternion (matrix) "Quaternion represented as a 4D Vector. Transforms rotation <b>matrix</b> into the corresponding quaternion. :arguments (matrix \"3x3 Orthonormal Rotation Matrix (as a Lisp Array of Numbers)\")" (when matrix (let ((q (make-array 4 :element-type 'double-float)) (i 0) j k (nxt (make-array 3 :initial-contents (list 1 2 0))) (tr (+ (aref matrix 0 0) (aref matrix 1 1) (aref matrix 2 2)))) (if (> tr 0.0) (let* ((s (sqrt (+ tr 1.0))) (w (/ s 2.0)) (s (/ 0.5 s))) (setf (aref q 0) (* (- (aref matrix 1 2) (aref matrix 2 1)) s) (aref q 1) (* (- (aref matrix 2 0) (aref matrix 0 2)) s) (aref q 2) (* (- (aref matrix 0 1) (aref matrix 1 0)) s) (aref q 3) w)) (progn (when (> (aref matrix 1 1) (aref matrix 0 0)) (setq i 1)) (when (> (aref matrix 2 2) (aref matrix i i)) (setq i 2)) (setq j (aref nxt i) k (aref nxt j)) (let ((s (sqrt (+ (- (aref matrix i i) (+ (aref matrix j j) (aref matrix k k))) 1)))) (setf (aref q i) (half s)) (when (not (zerop s)) (setq s (/ 0.5 s))) (setf (aref q 3) (* (- (aref matrix j k) (aref matrix k j)) s) (aref q j) (* (+ (aref matrix i j) (aref matrix j i)) s) (aref q k) (* (+ (aref matrix i k) (aref matrix k i)) s))))) (make-vector (aref q 0) (aref q 1) (aref q 2) (aref q 3)) ))) (defun matrix-to-rotation (matrix) (when matrix (if (and (zerop (- (aref matrix 0 1) (aref matrix 1 0))) (zerop (- (aref matrix 0 2) (aref matrix 2 0))) (zerop (- (aref matrix 1 2) (aref matrix 2 1)))) ;; ;; have singularity ;; (if (and (zerop (+ (aref matrix 0 1) (aref matrix 1 0))) (zerop (+ (aref matrix 0 2) (aref matrix 2 0))) (zerop (+ (aref matrix 1 2) (aref matrix 2 1))) (zerop (+ (aref matrix 0 0) (aref matrix 1 1) (aref matrix 2 2) -3))) ;; ;; have identity matrix ;; (make-vector 1 0 0 0) ;; ;; have 180-degree rotation singularity ;; (let ((angle pi) x y z (xx (half (+ (aref matrix 0 0) 1))) (yy (half (+ (aref matrix 1 1) 1))) (zz (half (+ (aref matrix 2 2) 1))) (xy (/ (+ (aref matrix 0 1) (aref matrix 1 0)) 4)) (xz (/ (+ (aref matrix 0 2) (aref matrix 2 0)) 4)) (yz (/ (+ (aref matrix 1 2) (aref matrix 2 1)) 4))) (cond ((and (> xx yy) (> xx zz)) (if (zerop xx) (setq x 0.0 y +half-sqrt-2+ z +half-sqrt-2+) (setq x (sqrt xx) y (/ xy x) z (/ xz x)))) ((> yy zz) (if (zerop yy) (setq x +half-sqrt-2+ y 0.0 z +half-sqrt-2+) (setq y (sqrt yy) x (div xy y) z (div yz y)))) (t (if (zerop zz) (setq x +half-sqrt-2+ y +half-sqrt-2+ z 0.0) (setq z (sqrt zz) x (/ xz z) y (/ yz z))))) (make-vector x y z angle))) (let* ((angle (acos (half (+ (aref matrix 0 0) (aref matrix 1 1) (aref matrix 2 2) (- 1))))) (s (sqrt (+ (expt (- (aref matrix 2 1) (aref matrix 1 2)) 2) (expt (- (aref matrix 0 2) (aref matrix 2 0)) 2) (expt (- (aref matrix 1 0) (aref matrix 0 1)) 2)))) (x (/ (- (aref matrix 2 1) (aref matrix 1 2)) s)) (y (/ (- (aref matrix 0 2) (aref matrix 2 0)) s)) (z (/ (- (aref matrix 1 0) (aref matrix 0 1)) s))) (make-vector x y z (- angle)))))) (defun degrees-to-radians (&rest args) "Number. Converts <b>degrees</b> to radians. :arguments (degrees \"Number\")" (apply #'degree args)) (defun acosd (theta) "Number. Returns the arc cosine of <b>theta</b>, converted into degrees. :arguments (theta \"Number. An angle in radians\")" (radians-to-degrees (acos theta))) (defun asind (theta) "Number. Returns the arc sine of <b>theta</b>, converted into degrees. :arguments (theta \"Number. An angle in radians\")" (radians-to-degrees (asin theta))) (defun atand (theta) "Number. Returns the arc tangent of <b>theta</b>, converted into degrees. :arguments (theta \"Number. An angle in radians\")" (radians-to-degrees (atan theta))) (defun normalize-points (points) (let ((first (first points))) (values (mapcar #'(lambda(point) (subtract-vectors point first)) points) first))) (defun midpoint (point1 point2) "3D Point. Returns the barycentric average (i.e. midpoint) of <b>point1</b> and <b>point2</b>. :arguments (point1 \"3D Point\" point2 \"3D Point\")" (if (coincident-point? point1 point2) point1 (translate-along-vector point1 (subtract-vectors point2 point1) (half (3d-distance point1 point2))))) (defun between? (point start end) (same-direction-vectors? (subtract-vectors point start) (subtract-vectors end point))) (defun curve-parameter-< (param-1 param-2) (< param-1 param-2)) (defun roughly-aligned-vectors? (vector1 vector2 &optional (degree-tolerance 90)) (< (angle-between-vectors-d vector1 vector2) degree-tolerance)) (defun distance-to-line (point line-point line-vector) "Number. Returns shortest distance from point to line." (let ((intersection (inter-line-plane line-point line-vector point line-vector))) (3d-distance point intersection))) (defun equi-space-points (start end &key npoints) "List of points. Returns a list of equally spaced points between start and end." (when (< npoints 2) (error "equi-space-points needs at least two.")) (let ((direction-vector (subtract-vectors end start)) (distance (/ (3d-distance start end) (1- npoints))) (current start)) (cons start (let (result) (dotimes (n (1- npoints) (nreverse result)) (let ((new (translate-along-vector current direction-vector distance))) (push new result) (setq current new))))))) (defun sort-points-along-vector (points vector) "List of points. Returns points in order along given vector." (let ((base-point (first points))) (let ((intersects (mapcar #'(lambda(point) (let ((intersect (inter-line-plane base-point vector point vector))) (list point intersect (let ((raw-distance (3d-distance base-point intersect))) (if (same-direction-vectors? (subtract-vectors intersect base-point) vector) raw-distance (- raw-distance)))))) points))) (mapcar #'first (sort intersects #'< :key #'third))))) (defun apply-make-point (list) "2D, 3D, or 4D point. This function takes a list of two, three, or four numbers rather than multiple arguments as with the make-point and make-vector macro. This is equivalent to calling the make-point or make-vector macro on the elements of this list. :arguments (list \"List of 2, 3, or 4 numbers. The coordinates for the point.\") " (make-point (first list) (second list) (third list))) (defmacro merge-display-controls (display-controls) "Plist of display controls. This macro \"merges\" the given display controls list with that coming as a trickle-down slot from the parent. It will replace any common keys and add any new keys. :arguments (display-controls \"Plist. The new display controls to be merged with the defaults from the parent\") " (let ((keys (gensym)) (reduced (gensym))) `(if (the parent) (let ((,keys (plist-keys ,display-controls))) (let ((,reduced (remove-plist-keys (the parent display-controls) ,keys))) (append ,display-controls ,reduced))) ,display-controls))) ;; ;; FLAG -- there is a simple formula using dot-vectors to compute this directly. ;; (see http://mathworld.wolfram.com/HessianNormalForm.html) ;; (defun in-halfspace? (p-plane u-plane p1 p2) (let ((intersect (inter-line-plane p1 (subtract-vectors p2 p1) p-plane u-plane))) (not (and intersect (between? intersect p1 p2))))) (defun gdl::convert-to-radial (plist) (let ((radial-number (second (getf plist :sequence))) (radial-keys (rest (rest (getf plist :sequence)))) (has-orientation? (getf plist :orientation)) (has-center? (getf plist :center)) (base-plist (remove-plist-key plist :sequence))) (append (radial-special-inputs radial-keys :has-orientation? has-orientation? :has-center? has-center?) base-plist `(:sequence (:radial ,radial-number))))) (defun radial-special-inputs (radial-keys &key has-orientation? has-center?) (print-variables radial-keys) (append `(:%radial-vector% (rotate-vector (the (face-normal-vector (the-child %radial-start-direction%))) (* (the-child index) (the-child %radial-angle%)) (the (face-normal-vector (the-child %radial-normal-direction%)))) :%radial-start-direction% ,(or (getf radial-keys :start-direction) :right) :%radial-normal-direction% ,(or (getf radial-keys :normal-direction) :top) :%radial-radius% ,(or (getf radial-keys :radius) `(half (ecase (the-child %radial-start-direction%) ((:left :right) (the width)) ((:front :rear) (the length)) ((:top :bottom) (the height))))) :%radial-angle% ,(or (getf radial-keys :angle) `(div 2pi (the-child aggregate number-of-elements)))) (unless (or has-orientation? (and (member :rotate? (plist-keys radial-keys)) (null (getf radial-keys :rotate?)))) '(:orientation (alignment (the-child %radial-normal-direction%) (the (face-normal-vector (the-child %radial-normal-direction%))) (the-child %radial-start-direction%) (the-child %radial-vector%)))) (unless has-center? `(:center (translate-along-vector (the center) (the-child %radial-vector%) (the-child %radial-radius%)))))) (defun gdl::convert-to-matrix (plist) (let ((matrix-axis-1 (second (getf plist :sequence))) (matrix-axis-2 (fourth (getf plist :sequence))) (has-center? (getf plist :center)) (base-plist (remove-plist-key plist :sequence))) (append (matrix-special-inputs matrix-axis-1 matrix-axis-2 :has-center? has-center?) base-plist `(:sequence ,(getf plist :sequence))))) (defun axis-to-direction (axis &key reverse?) (if reverse? (ecase axis (:lateral :left) (:longitudinal :front) (:vertical :bottom)) (ecase axis (:lateral :right) (:longitudinal :rear) (:vertical :top)))) (defun matrix-special-inputs (matrix-axis-1 matrix-axis-2 &key has-center?) (let ((direction-1 (axis-to-direction matrix-axis-1)) (direction-2 (axis-to-direction matrix-axis-2)) (direction-r1 (axis-to-direction matrix-axis-1 :reverse? t)) (direction-r2 (axis-to-direction matrix-axis-2 :reverse? t))) (unless has-center? `(%matrix-vector-1% (the-child quantify-box (face-normal-vector ,direction-1)) %matrix-dim-1% (ecase ,matrix-axis-1 (:lateral (the-child quantify-box width)) (:longitudinal (the-child quantify-box length)) (:vertical (the-child quantify-box height))) %matrix-dim-2% (ecase ,matrix-axis-2 (:lateral (the-child quantify-box width)) (:longitudinal (the-child quantify-box length)) (:vertical (the-child quantify-box height))) %matrix-child-dim-1% (ecase ,matrix-axis-1 (:lateral (the-child width)) (:longitudinal (the-child length)) (:vertical (the-child height))) %matrix-child-dim-2% (ecase ,matrix-axis-2 (:lateral (the-child width)) (:longitudinal (the-child length)) (:vertical (the-child height))) %matrix-vector-2% (the-child quantify-box (face-normal-vector ,direction-2)) %matrix-vector-r1% (the-child quantify-box (face-normal-vector ,direction-r1)) %matrix-vector-r2% (the-child quantify-box (face-normal-vector ,direction-r2)) %matrix-corner% (translate-along-vector (if (= (second (the-child number-of-elements)) 1) (the-child quantify-box center) (translate-along-vector (the-child quantify-box center) (the-child %matrix-vector-r1%) (half (- (the-child %matrix-dim-1%) (the-child %matrix-child-dim-1%))))) (the-child %matrix-vector-r2%) (if (= (fourth (the-child number-of-elements)) 1) 0 (half (- (the-child %matrix-dim-2%) (the-child %matrix-child-dim-2%))))) %matrix-increment-1% (if (= (second (the-child number-of-elements)) 1) 0 (div (- (the-child %matrix-dim-1%) (the-child %matrix-child-dim-1%)) (1- (second (the-child number-of-elements))))) %matrix-increment-2% (if (= (fourth (the-child number-of-elements)) 1) 0 (div (- (the-child %matrix-dim-2%) (the-child %matrix-child-dim-2%)) (1- (fourth (the-child number-of-elements))))) :center (translate-along-vector (translate-along-vector (the-child %matrix-corner%) (the-child %matrix-vector-1%) (* (first (the-child index)) (the-child %matrix-increment-1%))) (the-child %matrix-vector-2%) (* (second (the-child index)) (the-child %matrix-increment-2%))))))) (defun point-on-plane? (3d-point plane-point plane-normal &key (tolerance *zero-epsilon*)) "Boolean. Determines whether or not the <tt>3d-point</tt> lies on the plane specified by <tt>plane-point</tt> and <tt>plane-normal</tt>, within <tt>tolerance</tt>. :arguments (3d-point \"Point in question\" plane-point \"point on the known plane\" plane-normal \"normal to the known plane\") :&key ((tolerance *zero-epsilon*) \"Tolerance for points to be considered coincident.\") " (let ((intersect-point (inter-line-plane 3d-point plane-normal plane-point plane-normal))) (coincident-point? 3d-point intersect-point :tolerance tolerance))) (defun point-on-vector? (first-point second-point unknown-point &key (tolerance *zero-epsilon*)) "Boolean. Determines whether or not the <tt>unknown-point</tt> lies on the ray specified by the vector pointing from <tt>first-point</tt> to <tt>second-point</tt>, within <tt>tolerance</tt>. :arguments (first-point \"first point of vector\" second-point \"second point of vector\" unknown-point \"point in question\") :&key ((tolerance *zero-epsilon*) \"Tolerance for vectors to be considered same-direction.\") " (let ((known-vector (subtract-vectors second-point first-point)) (unknown-vector (subtract-vectors unknown-point first-point))) (same-direction-vectors? known-vector unknown-vector :tolerance tolerance)))
68,010
Common Lisp
.lisp
1,253
42.439745
282
0.576166
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5462f4cc587b905864a6d5fdd5f51086cb05fa47f89de5a92e99ba32115ff954
35,777
[ -1 ]
35,778
cl-pdf-patches.lisp
lisp-mirror_gendl/geom-base/prereqs/source/cl-pdf-patches.lisp
;;; cl-pdf copyright 2002-2005 Marc Battyani see license.txt for the details ;;; You can reach me at [email protected] or [email protected] ;;; The homepage of cl-pdf is here: http://www.fractalconcept.com/asp/html/cl-pdf.html (in-package :pdf) (defmacro with-page ((&rest args) &body body) `(let* ((*page* (make-instance 'page ,@args))) (with-standard-io-syntax ;; ;; FLAG -- DJC set *read-default-float-format* to be compatible with GDL's default. ;; (let ((*read-default-float-format* 'double-float)) (setf (content (content-stream *page*)) (with-output-to-string (*page-stream*) ,@body)))) t))
709
Common Lisp
.lisp
15
39.866667
91
0.632653
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
d83e8a4101e1d6bd8fe70072f5aae1a8fd6f924a6348fe744929d32e77f1c714
35,778
[ -1 ]
35,779
parameters.lisp
lisp-mirror_gendl/geom-base/prereqs/source/parameters.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (eval-when (:compile-toplevel :load-toplevel :execute) (defmacro make-vector (&rest args) "0D, 1D, 2D, 3D, or 4D Vector. (Internally this is the same as a Point) Returns a vector of double-floats from up to 4 numbers." (let ((array (gensym))) (ecase (length args) (0 `(make-array 0)) (1 `(let ((,array (make-array 1))) (setf (svref ,array 0) (coerce ,(first args) 'double-float)) ,array)) (2 `(let ((,array (make-array 2))) (setf (svref ,array 0) (coerce ,(first args) 'double-float)) (setf (svref ,array 1) (coerce ,(second args) 'double-float)) ,array)) (3 `(let ((,array (make-array 3))) (setf (svref ,array 0) (coerce ,(first args) 'double-float)) (setf (svref ,array 1) (coerce ,(second args) 'double-float)) (setf (svref ,array 2) (coerce ,(third args) 'double-float)) ,array)) (4 `(let ((,array (make-array 4))) (setf (svref ,array 0) (coerce ,(first args) 'double-float)) (setf (svref ,array 1) (coerce ,(second args) 'double-float)) (setf (svref ,array 2) (coerce ,(third args) 'double-float)) (setf (svref ,array 3) (coerce ,(fourth args) 'double-float)) ,array))))) (defmacro make-point (&rest args) "3D Point. (Internally this is the same as a 3D Vector) Returns a vector of double-floats from up to 4 numbers." `(make-vector ,@args))) (defvar *debug?* nil) (glisp:define-constant *nominal-x-vector* (make-vector 1 0 0)) (glisp:define-constant *nominal-y-vector* (make-vector 0 1 0)) (glisp:define-constant *nominal-z-vector* (make-vector 0 0 1)) (glisp:define-constant *nominal-x-vector-r* (make-vector -1 0 0)) (glisp:define-constant *nominal-y-vector-r* (make-vector 0 -1 0)) (glisp:define-constant *nominal-z-vector-r* (make-vector 0 0 -1)) (glisp:define-constant *nominal-x-array* #2a((1.0d0 0.0d0 0.0d0))) (glisp:define-constant *nominal-y-array* #2a((0.0d0 1.0d0 0.0d0))) (glisp:define-constant *nominal-z-array* #2a((0.0d0 0.0d0 1.0d0))) (glisp:define-constant *nominal-x-array-r* #2a((-1.0d0 0.0d0 0.0d0))) (glisp:define-constant *nominal-y-array-r* #2a((0.0d0 -1.0d0 0.0d0))) (glisp:define-constant *nominal-z-array-r* #2a((0.0d0 0.0d0 -1.0d0))) (glisp:define-constant *trimetric-normal-vector* (make-vector 0.8342367128320977 -0.4377640254359154 0.3352786378480434)) ;;(make-vector 0.83425635 -0.43777433 0.33528653) (glisp:define-constant *trimetric-normal-vector-left* (make-vector -0.8342367128320977 -0.4377640254359154 0.3352786378480434)) ;;(make-vector -0.83425635 -0.43777433 0.33528653) (glisp:define-constant *trimetric-normal-vector-right-rear* (make-vector 0.8342367128320977 0.4377640254359154 0.3352786378480434)) ;;(make-vector 0.83425635 0.43777433 0.33528653) (glisp:define-constant *trimetric-normal-vector-left-rear* (make-vector -0.8342367128320977 0.4377640254359154 0.3352786378480434)) ;;(make-vector -0.83425635 0.43777433 0.33528653) (glisp:define-constant +nominal-origin+ (make-point 0 0 0)) (glisp:define-constant +half-sqrt-2+ (half (sqrt 2.0))) (defparameter *standard-face-hts* (make-hash-table :test #'equalp)) (defparameter *line-thickness-default* 0.5) (defparameter *standard-views* (list :top *nominal-z-vector* :bottom *nominal-z-vector-r* :left *nominal-x-vector-r* :right *nominal-x-vector* :front *nominal-y-vector-r* :rear *nominal-y-vector* :trimetric *trimetric-normal-vector* :tri-r-r *trimetric-normal-vector-right-rear* :tri-l *trimetric-normal-vector-left* :tri-l-r *trimetric-normal-vector-left-rear*)) (defparameter *gs-text-alpha-bits* 4 "Integer. The amount of anti-aliasing for Ghostscript to apply to text when making PNG or JPEG images. Defaults to 4. Set to 0 for no antialiasing.") (defparameter *gs-graphics-alpha-bits* 4 "Integer. The amount of anti-aliasing for Ghostscript to apply to graphics when making PNG or JPEG images. Defaults to 4. Set to 0 for no antialiasing.") (defun point-expression (point) `(make-point ,(get-x point) ,(get-y point) ,(get-z point))) (glisp:define-constant +postnet-bits+ (make-array 10 :initial-contents '((t t nil nil nil) ;;0 (nil nil nil t t) ;;1 (nil nil t nil t) ;;2 (nil nil t t nil) ;;3 (nil t nil nil t) ;;4 (nil t nil t nil) ;;5 (nil t t nil nil) ;;6 (t nil nil nil t) ;;7 (t nil nil t nil) ;;8 (t nil t nil nil))) "[Constant] 2D Array of Boolean. Represents the encodings used by the US Post Office Postnet barcoding system. this will be included and documented in a future version of the GDL PDF output format.") (defparameter *hash-transforms?* t "Boolean. Controls whether the transformations of points from three-dimensional world coordinates to two-dimensional display coordinates are cached in memory. Set this to NIL to save memory at the expense of some execution speed. <i>Note: in the current GDL release, transform caching is temporarily disabled, so this parameter will have no effect.</i> Defaults to T.") (defparameter *view-transform-inverses-hash* (make-hash-table :test #'equalp)) ;; ;; used as dynamically bound variable in obj format and maybe other ;; formats which have to keep track of vertex counts. ;; (defparameter *vertex-count* nil) (glisp:define-constant +identity-3x3+ (make-array (list 3 3) :initial-contents '((1d0 0d0 0d0) (0d0 1d0 0d0) (0d0 0d0 1d0)))) (defparameter *zero-vector-checking?* t "Boolean. Indicates whether GDL should perform checks for zero-length vectors where nonzero-length vectors are expected. Defaults to T. Setting to NIL will increase execution speed marginally, at the cost of decreased safety. Modify the value of this parameter at your own risk.") (defparameter *break-leaders?* t "Boolean. Indicates whether to try making a gap in dimension leaders for the text block. Defaults to t.") (defparameter *dxf-translation* (make-vector 0 0)) (defparameter *raphael-translation* (make-vector 0 0)) (defparameter *svg-translation* (make-vector 0 0)) (glisp:define-constant +rear-vector+ (make-vector 0 1 0)) (glisp:define-constant +top-vector+ (make-vector 0 0 1)) (defparameter +lh-identity-matrix+ #2A((1.0 0.0 0.0)(0.0 -1.0 0.0)(0.0 0.0 1.0))) (defparameter *dxf-entity-id* nil)
7,828
Common Lisp
.lisp
129
51.937984
139
0.655186
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
9ca0d3079f8b5b913c1f60ae8e40b32a8901dc5ab7cedb6d68a93f55676cf33b
35,779
[ -1 ]
35,780
general-note.lisp
lisp-mirror_gendl/geom-base/text/source/general-note.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (defparameter *general-note-center-circ* nil) ;; ;; ;; Contributed by Liberating Insight, www.li.com, modified by Genworks. ;; ;; (define-object general-note (outline-specialization-mixin base-object) :documentation (:description "Creates a text note in the graphical view port and in a PDF DXF output file." :examples "<pre> (in-package :gdl-user) (define-object general-note-test (base-object) :computed-slots ((blocks-note (list \"David Brown\" \"Created by\" \"ABC 2\" \"Jane Smith\" \"Approved by\" \"CCD 2\")) (blocks-center (list '(-15 5 0) '(-40 5 0) '(-55 5 0) '(-15 15 0) '(-40 15 0) '(-55 15 0))) (blocks-width (list 30 20 10 30 20 10))) :objects ((title-block :type 'box :sequence (:size (length (the blocks-center))) :display-controls (list :color :red) :center (apply-make-point (nth (the-child index ) (the blocks-center))) :length 10 :width (nth (the-child index ) (the blocks-width)) :height 0) (general-note-sample :type 'general-note :sequence (:size (length (the blocks-note))) :center (the (title-block (the-child index)) center) :character-size 2.5 :strings (nth (the-child index) (the blocks-note))))) (generate-sample-drawing :objects (list-elements (make-object 'general-note-test)) :projection-direction (getf *standard-views* :top)) </pre>") :input-slots (("List of Strings. The text to be displayed in the note." strings nil) ("Number. Specifies the character size in drawing units." character-size 1) ("Number in Percentage. Adjusts the character width for PDF output. Defaults to 100." text-x-scale 100) ("Number in Percentage. Adjusts the character width for DXF output. Defaults to the text-x-scale." dxf-text-x-scale (the text-x-scale)) ("Number. The scale factor for DXF character size vs PDF character size. Default is 0.8" dxf-size-ratio 0.8) ("String. This names the DXF font for this general-note. Defaults to <tt>(the font)</tt>." dxf-font (the font)) ("Number. The start of text will be offset by this amount for DXF output. Default is 0." dxf-offset 0) ("Keyword symbol. Currently can be :bubble, :rectangle, or :none. Default is :none." outline-shape-type :none) ("String. The font for PDF. Possibilities for built-in PDF fonts are: <ul> <li>courier</li> <li>courier-bold</li> <li>courier-boldoblique</li> <li>courier-oblique</li> <li>helvetica</li> <li>helvetica-bold</li> <li>helvetica-boldoblique</li> <li>helvetica-oblique</li> <li>symbol</li> <li>times-roman</li> <li>times-bold</li> <li>times-bolditalic</li> <li>times-italic</li> <li>zapfdingbats</li> </ul> Defaults to \"Courier\"." font "Courier") ("3D-point. Center of the text. Specify this or start, not both. NOTE that the center is no longer defaulting (so that it can self-compute properly when start is specified), so it is necessary to explicitly give either start or center for general-note." center (if *general-note-center-circ* (the parent center) (translate (the start) :right (half (the width)) :front (- (half (the length)) (- (the character-size) (the inter-line-space)))))) ("3D-point. Start of the text. Specify this or center, not both." start (let ((*general-note-center-circ* t)) (translate (the center) :left (half (the width)) :rear (- (half (the length)) (- (the character-size) (the inter-line-space)))))) ("Keyword symbol, :left, :right, or :center. Justifies text with its box. Default is :left." justification :left) ("Number. Space between lines of text. Default is 1.2 times the character size." leading (* (the character-size) 1.2)) ("Boolean. Determines whether text is underlined." underline? nil) ("Number. Determines the width of the containing box. Default is the maximum-text-width." width (the maximum-text-width)) (length (- (* (the text-lines number-of-elements) (the leading)) (- (the leading) (the character-size)))) (height 1) (%corners% (unless (the underline?) (list (the (vertex :front :left :bottom)) (the (vertex :top :right :rear)))))) :computed-slots ((string-list (if (listp (the strings)) (the strings) (list (the strings)))) (inter-line-space (- (the leading) (the character-size))) ("Number. Convienence computation giving the maximum input width required to keep one line per string" maximum-text-width (first (sort (mapsend (list-elements (the text-lines)) :text-width) #'>))) (outline-objects (append (list-elements (the text-lines)) (remove-if #'(lambda(obj) (typep obj 'null-part)) (list-elements (the text-lines) (the-element underline))) (list (the outline-shape)))) (%lines-to-draw% (apply #'append (list-elements (the text-lines) (the-element %lines-to-draw%))))) :hidden-objects ((outline-shape :type (ecase (or (the outline-shape-type) :none) (:none 'null-part) (:bubble 'global-filleted-polyline) (:rectangle 'global-polyline)) :expansion (ecase (or (the outline-shape-type) :none) ((:none :rectangle) (* (the width) .1)) (:bubble (the-child default-radius))) :vertex-list (list (translate (the (vertex :left :rear :top)) :left (the-child expansion) :rear (* (the character-size) .3)) (translate (the (vertex :right :rear :top)) :right (the-child expansion) :rear (* (the character-size) .3)) (translate (the (vertex :right :front :top)) :right (the-child expansion)) (translate (the (vertex :left :front :top)) :left (the-child expansion)) (translate (the (vertex :left :rear :top)) :left (the-child expansion) :rear (* (the character-size) .3))) :default-radius (half (the length))) (text-lines :type 'text-line :sequence (:size (length (the string-list))) :text (nth (the-child index) (the string-list)) :pass-down (character-size text-x-scale font underline? width dxf-text-x-scale dxf-font dxf-offset dxf-size-ratio onclick-function ) :start (translate (the start) :front (* (the-child index)(the leading)) :right (ecase (the justification) (:left 0) (:center (the-child center-justify-space)) (:right (the-child right-justify-space))))))) (defparameter *text-line-center-circ* nil) (define-object text-line (;;outline-specialization-mixin base-object) :documentation (:description "Outputs a single line of text for graphical display.") :input-slots (text (underline? nil) (text-x-scale 100) dxf-text-x-scale dxf-font dxf-offset dxf-size-ratio (width (the text-width)) ("3D-point. Center of the text. Specify this or start, not both." center (if *text-line-center-circ* (the parent center) (translate (the start) :right (half (the text-width)) :rear (half (the character-size))))) ("3D-point. Start of the text. Specify this or center, not both." start (let ((*text-line-center-circ* t)) (translate (the center) :left (half (the text-width)) :front (half (the character-size))))) (corner (the start)) character-size font) :computed-slots ((length (the character-size)) (text-width (* (/ 100) (the text-x-scale) (pdf::text-width (the text) (pdf:get-font (the font)) (the character-size)))) (right-justify-space (- (the width) (the text-width))) (center-justify-space (half (the right-justify-space))) (%text-to-draw% (the text)) ;;(%lines-to-draw% (when (the underline?) (the underline %lines-to-draw%))) ;;(outline-objects (list (the underline))) (%corners% (list (the (vertex :front :left :bottom)) (the (vertex :top :right :rear))))) :objects ((underline :type (if (the underline?) 'line 'null-part) :start (the start) :end (translate (the start) :right (the text-width))))) ;; ;; FLAG -- update for auto-scaling outside base-view ;; (define-lens (pdf text-line)() :output-functions ((cad-output () (with-format-slots (view) (let ((view-scale (if view (the-object view view-scale-total) 1)) (corner (if view (the-object view (view-point (the corner))) (the corner)))) (let ((font-size (* (the character-size) view-scale)) (rotation (angle-between-vectors-d (if view (matrix*vector (the-object view view-transform-inverse) +rear-vector+ ) +rear-vector+) (the (face-normal-vector :rear)) +top-vector+))) (with-translated-state (:pdf corner) (write-the rgb-stroke-setting) (unless (zerop rotation) (pdf:rotate rotation)) (pdf:in-text-mode (pdf:set-font (pdf:get-font (the font)) font-size) (pdf:set-text-x-scale (the text-x-scale)) (pdf:draw-text (the %text-to-draw%)))))))))) (define-lens (dxf text-line)() :output-functions ((cad-output () (with-format-slots (view) (let ((view-scale (if view (the-object view view-scale-total) 1)) (corner (if view (the-object view (view-point (the corner))) (the corner)))) (let ((corner (add-vectors *dxf-translation* corner)) (font-size (* (the character-size) view-scale)) (rotation (if view (angle-between-vectors-d (matrix*vector (the-object view view-transform-inverse) +rear-vector+ ) (the (face-normal-vector :rear)) +top-vector+) 0))) (with-translated-state (:dxf corner) (format *stream* " 0 TEXT 5 ~a 100 AcDbEntity 100 AcDbText 10 ~3,15f 20 ~3,15f 40 ~3,15f 1 ~a~a 41 ~3,15f 100 AcDbText " (incf *dxf-entity-id*) (+ (get-x corner) (the dxf-offset)) (get-y corner) (* (the dxf-size-ratio) font-size) (the %text-to-draw%) (if (and rotation (not (zerop rotation))) (format nil "~% 50~%~2,5f" rotation) "") (div (the dxf-text-x-scale) 100) ;; (the dxf-font) ;; FLAG -- work the font back in. ) (write-the rgb-stroke-setting) )))))))
13,437
Common Lisp
.lisp
283
34.035336
111
0.548523
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c7ebdd4db94409e48062e1212c4c0163236cd4c1dbf17b5eda04967b58c9c9af
35,780
[ -1 ]
35,781
typeset-block.lisp
lisp-mirror_gendl/geom-base/text/source/typeset-block.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (defparameter *typeset-block-center-circ* nil) (define-object typeset-block (base-object) :documentation (:description "Block of text typeset using cl-typesetting. This object wraps the typeset block as a standard GDL object, so it can be placed in a view and positioned according to normal GDL positioning. You can specify the width, and by default this object will compute its length automatically from the typeset content, to fit all the lines of text into the box. Because of this computed behavior of the length, the center of the box will not, in general, be in a known location compared to the start of the text. Because of this it is recommended to use :corner, rather than :center, for positioning a base-view which contains a typeset block. In the normal case, if you want a single block in a view on a drawing, you should make the base-view object have the same width and length as the typeset-block. The base-view should also probably have :left-margin 0 and :front-margin 0.") :input-slots ( ("Number. The line number to start" start-line-index nil) ("3D-point. Center of the text. Specify this or start, not both. NOTE that the center is no longer defaulting (so that it can self-compute properly when start is specified), so it is necessary to explicitly give either start or center for general-note." center (if *typeset-block-center-circ* (the parent center) (translate (the start) :right (half (the width)) :front (half (the length))))) ("Number. The length of the box to contain the compiled content. Defaults is (the length-default), which will exactly fit the compiled content into the specified width. If you override it to be less than this default, the content will be cropped." length (the length-default)) ("3D-point. Start of the text. Specify this or center, not both." start (let ((*typeset-block-center-circ* t)) (translate (the center) :left (half (the width)) :rear (half (the length)))))) :computed-slots ((end-line-plist (let ((lines (coerce (the lines) 'array)) (block-length (the length))) (let ((lines-length (length lines))) (print-variables lines-length)) (do* ((i (or (the start-line-index) 0) (1+ i)) (line (aref lines i) (aref lines i)) (y (typeset::dy line) (typeset::dy line)) (y-sum y (+ y-sum y))) ((or (>= y-sum block-length) (= i (1- (array-dimension lines 0)))) (list :end-line-index (1- i) :length (- y-sum y))) (let ((array-dim (array-dimension lines 0))) (print-variables array-dim i y y-sum block-length)) ))) (end-line-index (when (the start-line-index) (getf (the end-line-plist) :end-line-index))) ("List of typeset line objects. The list of lines in the nominal block." lines (typeset::fit-lines (the content) (the width) most-positive-fixnum )) ("Number. The computed length which will exactly fit the content based on (the width)." length-default (if (the start-line-index) (getf (the end-line-plist) :length) (reduce #'+ (mapcar #'typeset::dy (the lines))))) (%corners% (list (the (vertex :top :left :rear)) (the (vertex :top :right :rear)) (the (vertex :top :right :front)) (the (vertex :top :left :front)))) (content-block (the content)) (boxes (typeset::boxes (the content-block))) ) ;;:objects ((box :type 'box)) :input-slots ((content nil))) ;; FLAG -- document and remove funcall when cl-typesetting stabilized. ;; ;; ;; FLAG -- update for auto-scaling outside base-view ;; (define-lens (pdf typeset-block)() :output-functions ((cad-output () (with-format-slots (view) (let ((view-scale (if view (the-object view view-scale-total) 1)) (start (if view (if (and (the-object view parent) (find-package :gwl) (typep (the-object view parent) (read-from-string "gwl:web-drawing"))) (the start) (the-object view (view-point (the start)))) (the start)))) (let ((rotation (angle-between-vectors-d +rear-vector+ (the (face-normal-vector :rear)) +top-vector+))) (pdf:with-saved-state (pdf:scale view-scale view-scale) (with-translated-state (:pdf start) (write-the rgb-stroke-setting) (unless (zerop rotation) (pdf:rotate rotation)) (when (the content) (funcall (symbol-function (read-from-string "typeset::gdl-draw-block")) (the content) 0 0 (the width) (max (the length) (the length-default)) ;;10000 :start-line (the start-line-index) :end-line (the end-line-index) :all-lines (the lines))) (pdf:in-text-mode (write-the additional-output)) (write-the additional-non-text))))))) (additional-output ()) (additional-non-text ()))) (define-object typeset-blocks () :input-slots (full-block length width) :computed-slots ((number-of-blocks (let ((number-of-blocks 1)) (do ((block (make-object (the full-block type) :start-line-index 0 :length (the length) :width (the width)) (make-object (the full-block type) :start-line-index (the-object block end-line-index) :length (the length) :width (the width)))) ;; ;; FLAG -- why does this need to be 2 lines early? ;; ((>= (the-object block end-line-index) (- (length (the full-block lines)) 2)) number-of-blocks) (let ((end-line-index (the-object block end-line-index)) (full-block-lines-length (length (the full-block lines)))) (print-variables end-line-index full-block-lines-length number-of-blocks) (incf number-of-blocks)))))) :objects ((blocks :type (the full-block type) :sequence (:size (the number-of-blocks)) :width (the width) :length (the length) :start-line-index (if (the-child first?) 0 (the-child previous end-line-index))))) (in-package :typeset) (defmethod gdl-draw-block (content x y dx dy &key border (padding 5) rotation (v-align :top) special-fn start-line end-line all-lines) ;;; On the current *page* (pdf:with-saved-state (pdf:translate x y) (when rotation (pdf:rotate rotation)) (when border (with-quad (left top right bottom) padding (pdf:set-line-width border) (pdf:set-gray-stroke 0) (pdf:set-gray-fill 1) (pdf:basic-rect (- left) top (+ dx left right) (- (+ dy top bottom))) (pdf:fill-and-stroke) (pdf:set-gray-fill 0))) (let ((vbox (if (and start-line end-line) (make-filled-vbox-from-part content dx dy :v-align v-align :start-line start-line :end-line end-line :all-lines all-lines) (make-filled-vbox content dx dy v-align)))) (when special-fn (funcall special-fn vbox 0 0)) (stroke vbox 0 0)))) (defun make-filled-vbox-from-part (content dx dy &key (v-align :top) (advance t) start-line end-line all-lines) (with-text-content (content) (let* ((lines (or all-lines (fit-lines content dx dy v-align advance))) (length (length lines))) (gdl:print-variables length) (multiple-value-bind (boxes) (subseq lines start-line end-line) (when boxes (let* ((vbox (make-instance 'vbox :dx dx :dy dy :boxes boxes :fixed-size t))) (do-layout vbox) vbox))))))
10,611
Common Lisp
.lisp
191
37.963351
117
0.532145
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
96b745d5aa76b460fc617d633279618ba32f586f4822a6ebce79e00b0a6712e2
35,781
[ -1 ]
35,782
tests.lisp
lisp-mirror_gendl/geom-base/text/source/tests.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object general-note-drawing (base-drawing) :objects ((main-view :type 'base-view :objects (list (the general-notes center-note))) (general-notes :type 'general-notes))) (define-object general-notes (base-object) :input-slots ((underline? t) (text-x-scale 115) ) :computed-slots ((strings (list "You are in a dimly lit" "room in a cave." "In each direction you look," "you see twisty little passages," "all different."))) :objects ((left-note :type 'general-note :pass-down (strings underline? text-x-scale)) (center-note :type 'general-note :justification :center :outline-shape-type :bubble :pass-down (strings underline? text-x-scale)) (right-note :type 'general-note :justification :right :pass-down (strings underline? text-x-scale)) (left-note-45-degree :type 'general-note :pass-down (strings underline? text-x-scale) :orientation (alignment :rear (rotate-vector-d (the (face-normal-vector :rear)) 45 (the (face-normal-vector :top))))) (center-note-45-degree :type 'general-note :pass-down (strings underline? text-x-scale) :justification :center :orientation (alignment :rear (rotate-vector-d (the (face-normal-vector :rear)) 45 (the (face-normal-vector :top))))) (right-note-45-degree :type 'general-note :pass-down (strings underline? text-x-scale) :justification :right :orientation (alignment :rear (rotate-vector-d (the (face-normal-vector :rear)) 45 (the (face-normal-vector :top))))) )) (define-object multi-column-ron (base-drawing) :objects ((ron-block :type 'ron-paul-block :width (half (the width))) (ron-blocks :type 'typeset-blocks :full-block (the ron-block) :width (half (the width)) :length 200) (ron-views :type 'base-view :border-box? t :front-margin 0 :left-margin 0 :sequence (:matrix :lateral 2 :longitudinal (half (the ron-blocks blocks number-of-elements))) :flat-index (+ (* (first (the-child index)) 2) (second (the-child index))) :objects (list (the ron-blocks (blocks (the-child flat-index)))) :width (the ron-blocks width) :length (the ron-blocks (blocks (the-child flat-index)) length)) (full-view :type 'base-view :left-margin 0 :front-margin 0 :border-box? t))) (define-object ron-paul-block (typeset-block) :input-slots ((width 250)) :functions ((content () (typeset:compile-text () (typeset:paragraph () " Ronald Ernest Paul (born August 20, 1935) is a Republican United States Congressman from Lake Jackson, Texas, a physician, a bestselling author, and the last Republican candidate to withdraw from the 2008 U.S. presidential election.") (typeset:paragraph () " Originally from the Green Tree suburb of Pittsburgh, Pennsylvania, he graduated from Gettysburg College in 1957, then studied at Duke University School of Medicine; after his 1961 graduation and a residency in obstetrics and gynecology, he became a U.S. Air Force flight surgeon, serving outside the Vietnam War zone. He later represented Texas districts in the U.S. House of Representatives (1976–1977, 1979–1985, and 1997–present). He entered the 1988 presidential election, running as the Libertarian nominee while remaining a registered Republican, and placed a distant third.") (typeset:paragraph () " Paul has been described as conservative, Constitutionalist, and libertarian.[2] He advocates a foreign policy of nonintervention, having voted against actions such as the Iraq War Resolution, but in favor of force against terrorists in Afghanistan. He favors withdrawal from the North Atlantic Treaty Organization and the United Nations, citing the dangers of foreign entanglements to national sovereignty. Having pledged never to raise taxes, he has long advocated ending the federal income tax, scaling back government spending, abolishing most federal agencies, and removing military bases and troops from foreign soil; he favors hard money and opposes the Federal Reserve. He also opposes the Patriot Act, the federal War on Drugs, No Child Left Behind, and gun regulation. Paul is strongly pro-life, and has introduced bills to negate Roe v. Wade, but affirms states' rights to allow, regulate or ban abortion, rather than federal jurisdiction.[3]") (typeset:paragraph () "While Paul was a leading 2008 presidential candidate in some Republican straw polls, he saw substantially less support in landline opinion polls and in the actual primaries. Strong internet grassroots support was indicated by the popularity of his name in search queries and the number of his campaign's YouTube subscriptions. His book, The Revolution: A Manifesto, became a bestseller immediately upon release[4][5][6][7][8] and went on to become on the New York Times nonfiction best sellers list.[9]")))))
6,909
Common Lisp
.lisp
133
40.112782
109
0.62812
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
1f9a78d71286865139ade21dd016db22765a985b5220d46fa883b94f16447498
35,782
[ -1 ]
35,783
angular-dimension.lisp
lisp-mirror_gendl/geom-base/annotations/source/angular-dimension.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object angular-dimension (linear-dimension) :documentation (:description "This dimensional object produces a clear and concise arc dimensional annotation." :examples "<pre> (in-package :gdl-user) (define-object angular-dimension-test (base-object) :objects ((arc :type 'arc :display-controls (list :color :green ) :radius 30 :end-angle (degrees-to-radians 90)) (dimension :type 'angular-dimension :display-controls (list :color :blue ) :leader-radius (+ (* 0.1 (the arc radius))(the arc radius)) :arc-object (the arc)) (explicit-dimension :type 'angular-dimension :center-point (the arc center) :start-point (the arc (point-on-arc (degrees-to-radians 10))) :end-point (the arc (point-on-arc (degrees-to-radians 60)))))) (generate-sample-drawing :objects (list (the-object (make-object 'angular-dimension-test) arc) (the-object (make-object 'angular-dimension-test) dimension) (the-object (make-object 'angular-dimension-test) explicit-dimension)) :projection-direction (getf *standard-views* :top)) </pre>") :input-slots ("GDL object. The arc being measured." arc-object ("3D Point. The center of the arc being measured." center-point (the arc-object center)) ("3D Point. The start point of the arc being measured." start-point (the arc-object start)) ("3D Point. The end point of the arc being measured." end-point (the arc-object end)) ("Number. The radius for the leader-arc." leader-radius (+ (the witness-line-length) (max (3d-distance (the center-point) (the start-point)) (3d-distance (the center-point) (the end-point))))) ("Number. Amount of padding above leader for text-along-leader? t. This is multiplied by the character-size to get the actual padding amount. Defaults to 1/3." text-along-leader-padding-factor 1/3) ("Boolean. Determines whether a witness line extends all the way from the start-point to the center. Defaults to nil." witness-1-to-center? nil) ("Boolean. Determines whether a witness line extends all the way from the end-point to the center. Defaults to nil." witness-2-to-center? nil) ("3D Point. Determines where the text will start. Defaults to halfway along the arc, just beyond the radius." dim-text-start (translate-along-vector (the center-point) (rotate-vector (the witness-direction-vector-1) (half (angle-between-vectors (the witness-direction-vector-1) (the witness-direction-vector-2) (the (face-normal-vector :top)))) (the (face-normal-vector :top))) (if (the text-above-leader?) (the leader-radius) (the leader-radius))))) :computed-slots ((witness-direction-vector-1 (subtract-vectors (the start-point) (the center-point))) (witness-direction-vector-2 (subtract-vectors (the end-point) (the center-point))) (witness-line-length-1 (the witness-line-length)) (witness-line-length-2 (the witness-line-length)) (leader-start (translate-along-vector (the start-point) (the witness-direction-vector-1) (+ (the witness-line-length-1) (the witness-line-gap)))) (leader-end (let ((nominal (translate-along-vector (the end-point) (the witness-direction-vector-2) (+ (the witness-line-length-2) (the witness-line-gap))))) (if (and (not (the outside-leaders?)) (the full-leader-line-length)) (translate-along-vector (the leader-start) (subtract-vectors nominal (the leader-start)) (the full-leader-line-length)) nominal))) (dimension-angle (angle-between-vectors (the witness-direction-vector-1) (the witness-direction-vector-2))) (dim-value (radians-to-degrees (the dimension-angle))) (%curves-to-draw% (the full-leader arc %curves-to-draw%)) (%arcs% (the full-leader arc %arcs%))) :hidden-objects ((full-leader :type 'leader-arc :path-points (list (the leader-start) (the leader-end)) :radius (the leader-radius) :pass-down (center-point witness-direction-vector-1 witness-direction-vector-2 arrowhead-style arrowhead-style-2 arrowhead-length arrowhead-width)) (leader-1 :type 'null-part ;; FLAG -- fill in for conditions requiring this. ) (leader-2 :type 'null-part ;; FLAG -- fill in for conditions requiring this. ) (witness-line-1 :type (if (the witness-line?) 'line 'null-part) :start (if (the witness-1-to-center?) (the center-point) (the start-point)) :end (translate-along-vector (the center-point) (the witness-direction-vector-1) (+ (the leader-radius) (the witness-line-ext)))) (witness-line-2 :type (if (the witness-line-2?) 'line 'null-part) :start (if (the witness-2-to-center?) (the center-point) (the end-point)) :end (translate-along-vector (the center-point) (the witness-direction-vector-2) (+ (the leader-radius) (the witness-line-ext)))) (dimension-text :type 'general-note :pseudo-inputs (start-center) :start-center (let ((point (add-vectors (the dim-text-start) (the dim-text-start-offset)))) (translate-along-vector point (subtract-vectors point (the center-point)) (* (the text-along-leader-padding-factor) (the character-size)))) :start (translate-along-vector (the-child start-center) (the-child (face-normal-vector :left)) (half (the-child width))) :strings (ensure-list (the dim-text)) :orientation (if (the text-along-axis?) (alignment :top (the (face-normal-vector :top)) :right (cross-vectors (subtract-vectors (the-child start-center) (the center-point)) (the (face-normal-vector :top)))) (the orientation)) :pass-down (font character-size))))
8,929
Common Lisp
.lisp
145
41
113
0.529999
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7554434b41b332113200d257fe2f0361c82bd2af3c70a70b1399fb87d155af54
35,783
[ -1 ]
35,784
parallel-dimension.lisp
lisp-mirror_gendl/geom-base/annotations/source/parallel-dimension.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object parallel-dimension (linear-dimension) :documentation (:description "Creates a dimension annotation along an axis from a start point to an end point." :examples "<pre> (in-package :gdl-user) (define-object parallel-dimension-sample (base-object) :objects ((box :type 'box :length 10 :width (* (the-child length) +phi+) :height (* (the-child :width) +phi+)) (length-dimension :type 'parallel-dimension :character-size (/ (the box length) 20) :start-point (the box (vertex :top :left :front)) :end-point (the box (vertex :top :right :rear))))) (generate-sample-drawing :object-roots (make-object 'parallel-dimension-sample)) </pre>") :input-slots (("3D Point. Determines where the text will start. Defaults to reasonable location for horizontal-dimension." dim-text-start (let ((mid-point (translate-along-vector (the leader-start) (subtract-vectors (the leader-end) (the leader-start)) (half (3d-distance (the leader-start) (the leader-end)))))) (let ((center (cond ((and (not (the outside-leaders?)) (the text-above-leader?) (the text-along-axis?)) (translate-along-vector mid-point (the rear-vector) (* (the dim-text-above-gap-factor) (half (the dimension-text length))))) ((and (not (the outside-leaders?)) (not (the text-above-leader?)) (the text-along-axis?)) mid-point) ((and (not (the outside-leaders?)) (the text-above-leader?) (not (the text-along-axis?))) (translate-along-vector mid-point (the rear-vector) (half (the dimension-text width)))) ((and (not (the outside-leaders?)) (not (the text-above-leader?)) (not (the text-along-axis?))) (translate-along-vector mid-point (the front-vector) (half (the dimension-text width)))) (t (ecase (the dim-text-bias) (:center mid-point) (:start (translate-along-vector (the leader-start) (if (the start-end-swapped?) (the rear-vector) (the front-vector)) (+ (the leader-line-length) (half (the dimension-text width))))) (:end (translate-along-vector (the leader-end) (if (the start-end-swapped?) (the rear-vector) (the front-vector)) (+ (half (the dimension-text width)) (the leader-line-length-2))))))))) (translate-along-vector (translate-along-vector center (the left-vector) (half (the dimension-text width))) (the front-vector) (half (the dimension-text length))))))) :computed-slots ((left-vector (the dimension-text (face-normal-vector :left))) (right-vector (the dimension-text (face-normal-vector :right))) (front-vector (the dimension-text (face-normal-vector :front))) (rear-vector (the dimension-text (face-normal-vector :rear))) (full-leader-break-points (when (and *break-leaders?* (not (the text-above-leader?))) (let ((start (the leader-start)) (end (the leader-end)) (overage (* .2 (the dimension-text width)))) (let ((start-end-vector (subtract-vectors end start))) (let ((first (translate-along-vector start start-end-vector (- (3d-distance start (the dim-text-start)) overage)))) (list first (translate-along-vector first start-end-vector (+ (twice overage) (the dimension-text width))))))))) (witness-direction-vector (cross-vectors (if (the flip-leaders?) (the leader-direction-1-vector) (the leader-direction-2-vector)) (the top-vector))) (top-vector (if (parallel-vectors? (subtract-vectors (the start-point) (the end-point)) (the (face-normal-vector :top))) (the (face-normal-vector :rear)) (the (face-normal-vector :top)))) (leader-direction-1-vector (orthogonal-component (subtract-vectors (the start-point) (the end-point)) (the top-vector))) (leader-direction-2-vector (reverse-vector (the leader-direction-1-vector))) (base-plane-normal (the witness-direction-vector))))
7,193
Common Lisp
.lisp
114
37.850877
124
0.465837
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
986e26c5988e9b475ef752365459398afc177a7a6c0fdf5dc9c444472fa08af5
35,784
[ -1 ]
35,785
vertical-dimension.lisp
lisp-mirror_gendl/geom-base/annotations/source/vertical-dimension.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object vertical-dimension (linear-dimension) :documentation (:description "Creates a dimension annotation along the vertical axis." :examples "<pre> (in-package :gdl-user) (define-object vertical-dimension-sample (base-object) :objects ((box :type 'box :length 10 :width (* (the-child length) +phi+) :height (* (the-child :width) +phi+)) (length-dimension :type 'vertical-dimension :character-size (/ (the box length) 20) :flip-leaders? t :start-point (the box (vertex :top :left :front)) :end-point (the box (vertex :top :left :rear))))) (generate-sample-drawing :object-roots (make-object 'vertical-dimension-sample)) </pre>") :input-slots (("3D Point. Determines where the text will start. Defaults to reasonable location for horizontal-dimension." dim-text-start (let ((mid-point (translate-along-vector (the leader-start) (subtract-vectors (the leader-end) (the leader-start)) (half (3d-distance (the leader-start) (the leader-end)))))) (let ((center (cond ((and (not (the outside-leaders?)) (the text-above-leader?) (the text-along-axis?)) (translate mid-point :left (* (half (the dimension-text length)) (the dim-text-above-gap-factor)))) ((and (not (the outside-leaders?)) (not (the text-above-leader?)) (the text-along-axis?)) mid-point) ((and (not (the outside-leaders?)) (the text-above-leader?) (not (the text-along-axis?))) ;;(translate mid-point :left (half (the dimension-text width))) mid-point ) ((and (not (the outside-leaders?)) (not (the text-above-leader?)) (not (the text-along-axis?))) mid-point) (t (ecase (the dim-text-bias) (:center mid-point) (:start (translate (the leader-start) (if (the start-end-swapped?) :rear :front) (+ (the leader-line-length) (half (the dimension-text width))))) (:end (translate (the leader-end) (if (the start-end-swapped?) :rear :front) (+ (half (the dimension-text width)) (the leader-line-length-2))))))))) (translate-along-vector (translate-along-vector center (the dimension-text (face-normal-vector :left)) (half (the dimension-text width))) (the dimension-text (face-normal-vector :front)) (half (the dimension-text length))))))) :computed-slots ((sample-point-direction :rear) (witness-direction-vector (the (face-normal-vector (if (the flip-leaders?) :left :right)))) ;; ;; FLAG -- adjust for start-end-swapped? t ;; (leader-direction-1-vector (the (face-normal-vector (if (the start-end-swapped?) :rear :front)))) (leader-direction-2-vector (the (face-normal-vector (if (the start-end-swapped?) :front :rear)))) (base-plane-normal (the (face-normal-vector :right)))))
5,485
Common Lisp
.lisp
91
36.384615
101
0.474806
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e5f5256871d7a09f681cd424fdae044e5f13da305f26fed0af4fa191bc6c0024
35,785
[ -1 ]
35,786
label.lisp
lisp-mirror_gendl/geom-base/annotations/source/label.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object label (outline-specialization-mixin base-object) :documentation (:description "Produces a text label for graphical output" :examples "<pre> (in-package :gdl-user) (define-object label-sample (base-object) :objects ((box :type 'box :length 10 :width (* (the-child length) +phi+) :height (* (the-child :width) +phi+)) (corner-label :type 'label :leader-path (let ((start (the box (vertex :top :right :rear)))) (list start (translate start :right (/ (the box width) 10) :rear (/ (the box width) 10)) (translate start :right (/ (the box width) 7) :rear (/ (the box width) 10)))) :text \"The Corner\" :character-size (/ (the box width) 15)))) (generate-sample-drawing :object-roots (make-object 'label-sample)) </pre>") :input-slots ("List of 3D Points. List making up leader line, starting from where the arrowhead normally is." leader-path ("Width of arrowhead glyph. Defaults to five times the line thickness (2.5)" arrowhead-width (half (the character-size))) ("Length (from tip to tail) of arrowhead glyph. Defaults to twice the <tt>arrowhead-width</tt>" arrowhead-length (* (the arrowhead-width) 2)) ("Keyword Symbol. Style for arrowhead at start of <tt>leader-path</tt>. Currently supported values are <tt>:none</tt>, <tt>:wedge</tt> (the Default), and <tt>:double-wedge</tt>." arrowhead-style :wedge) ("Keyword Symbol. Style for arrowhead on end of <tt>leader-path</tt>. Currently supported values are <tt>:none</tt> (the Default), <tt>:wedge</tt>, and <tt>:double-wedge</tt>." arrowhead-style-2 :none) ("String. Text to be displayed as the label" text "") ("List of strings. Text lines to be displayed as the label. Specify this or text, not both." strings nil) ("String naming a standard PDF font. Font for the label text. Defaults to \"Helvetica\"" font "Helvetica") ("Number. Size (glyph height) of the label text, in model units. Defaults to 10." character-size 10) ("Number. Amount of space between last point in leader-path and beginning of the label text. Defaults to the width of the letter \"A\" in the specified <tt>font</tt> and <tt>character-size</tt>." text-gap (pdf::text-width "A" (pdf:get-font (the font)) (the character-size))) ("Keyword Symbol, either <tt>:left</tt> or <tt>:right</tt>. Determines whether the label text sits to the right or the left of the last point in the <tt>leader-path</tt>. The default is computed based on the direction of the last segment of the leader-path." text-side (let ((test-point (translate (first (the leader-path)) :right (3d-distance (first (the leader-path)) (lastcar (the leader-path)))))) (if (> (3d-distance test-point (first (the leader-path))) (3d-distance (lastcar (the leader-path)) (first (the leader-path)))) :left :right))) ("Keyword Symbol. Indicates shape of outline enclosing the text. Currently <tt>:none</tt>, <tt>:bubble</tt>, <tt>:rectangle</tt>, and <tt>nil</tt> are supported. The default is nil" outline-shape-type nil) ("GDL object or NIL. View object which will use this dimension. Defaults to NIL." view-reference-object nil) (text-x-scale 100) ("Number in Percentage. Adjusts the character width for DXF output. Defaults to the text-x-scale." dxf-text-x-scale (the text-x-scale)) ("Number. The scale factor for DXF character size vs PDF character size. Default is 0.8" dxf-size-ratio 0.8) ("String. This names the DXF font for this general-note. Defaults to <tt>(the font)</tt>." dxf-font (the font)) ("Number. The start of text will be offset by this amount for DXF output. Default is 2." dxf-offset 3) (%vertex-array% (coerce (append (the leader-path) (coerce (the note %corners%) 'list)) 'vector))) :computed-slots ((orientation (when (the view-reference-object) (the view-reference-object orientation)))) :hidden-objects ((leader :type (if (the leader-path) 'leader-line 'null-part) :path-points (the leader-path) :pass-down (arrowhead-width arrowhead-length arrowhead-style arrowhead-style-2)) (note :type 'general-note :start (ecase (the text-side) (:right (translate (lastcar (the leader-path)) :right (the text-gap))) (:left (translate (lastcar (the leader-path)) :left (+ (the text-gap) (the-child width))))) :strings (or (ensure-list (the strings)) (ensure-list (the text))) :pass-down (onclick-function font outline-shape-type character-size dxf-text-x-scale dxf-size-ratio dxf-font dxf-offset))))
6,093
Common Lisp
.lisp
104
48.711538
133
0.640916
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
04ba88c5765968a372b25b66cf29206e870bd35b043f4701b253dc222708fd88
35,786
[ -1 ]
35,787
tests.lisp
lisp-mirror_gendl/geom-base/annotations/source/tests.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) #| NOTE: before compiling/loading this file, do: (cl-lite "~/<genworks>/gdl/src/demos/robot/") |# #+nil (defun run-tests () "Initiate all test in file" (ang) (draw 'dxf) (draw 'pdf) (draw 'png) (cont) (contp) (draw2 'dxf) (draw2 'pdf) (draw2 'png) ;;(draw3 'dxf) ;;(draw3 'pdf) ;;(draw3 'png) ) #+nil (define-object vertical-0 (base-object) :input-slots ((length 1)(width 3)(height 0) (character-size 0.125)) :objects ((p1 :type 'point :center (the (vertex :left :front :top))) (p2 :type 'point :center (the (vertex :right :rear :top))) (d1 :type 'vertical-dimension :pass-down (character-size) :start-point (the p1 center) :end-point (the p2 center)) (d2 :type 'vertical-dimension :pass-down (character-size) :start-point (the p2 center) :end-point (the p1 center) :witness-line-length 0.5 :flip-leaders? t :outside-leaders? t :text-above-leader? t :leader-line-length 0.5 :arrowhead-style :triangle))) #+nil (define-object vertical-1-drawing (base-drawing) :objects ((vert :type 'vertical-dimension :arrowhead-style :none :arrowhead-style-2 :none :start-point (the box (vertex :top :right :front)) :end-point (the box (vertex :top :right :rear))) (box :type 'box :length 10 :width 20 :height 0) (poly :type 'global-polyline :vertex-list (list (make-point 0 0 0) (make-point 1 1 0) (make-point 2 0 0) )) (main :type 'base-view :objects (list (the box) (the poly) (the vert) )))) #+nil (define-object vertical-1 (base-object) :computed-slots ((start-point (make-point 449.8032 0 0)) (end-point (make-point 405.42 -195 0))) :objects ( (vertical :type 'vertical-dimension :pass-down (start-point end-point)))) #+nil (define-object vertical-2 (base-object) :objects ((box :type 'box :length 10 :width (* (the-child length) +phi+) :height (* (the-child :width) +phi+)) (length-dimension :type 'vertical-dimension :font-size (/ (the box length) 20) :arrowhead-width (/ (the-child font-size) 3) :flip-leaders? t :start-point (the box (vertex :top :left :front)) :end-point (the box (vertex :top :left :rear))))) #+nil (define-object horizontal-1 (base-object) :objects ((box :type 'box :length 10 :width (* (the-child length) +phi+) :height (* (the-child :width) +phi+)) (width-dimension :type 'horizontal-dimension :font-size (/ (the box length) 20) :arrowhead-width (/ (the-child font-size) 3) :start-point (the box (vertex :top :left :rear)) :end-point (the box (vertex :top :right :rear))))) #+nil (define-object par-1-draw (base-drawing) :objects ((par :type 'parallel-1) (main-view :type 'base-view :objects (list ;;(the par box) (the par length-dimension) )))) #+nil (define-object parallel-1 (base-object) :objects ((box :type 'box :length 10 :width (* (the-child length) +phi+) :height (* (the-child :width) +phi+)) (length-dimension :type 'parallel-dimension :text-along-axis? t :text-above-leader? t :font-size (/ (the box length) 20) :arrowhead-width (/ (the-child font-size) 3) :start-point (the box (vertex :top :left :front)) :end-point (the box (vertex :top :right :rear))))) #+nil (define-object angular-1 (base-drawing) :input-slots ((length 792) (width 612) (character-size 0.1)) :computed-slots ((p1 (translate (the center) :right 2.0 :rear 0.0)) (p2 (translate (the center) :right 1.8 :rear 1.2)) (p3 (translate (the center) :right 0.25 :rear 1.0)) (p4 (translate (the center) :right -0.25 :rear 1.0))) :hidden-objects ((main-view :type 'base-view :border-box? t :objects (set-difference (the hidden-children) (list (the main-view)) :test #'eql)) (center-point :type 'point :center (the center)) (point-1 :type 'point :center (the p1)) (point-2 :type 'point :center (the p2)) (point-3 :type 'point :center (the p3)) (point-4 :type 'point :center (the p4)) (inside-part :type 'angular-dimension ;;:pass-down (character-size) :character-size 0.3 :center-point (the center) :start-point (the p1) :end-point (the p2) :text-along-axis? t :witness-1-to-center? t ;;:dim-text-start-offset (make-vector .05 .05 0) ) (above-part :type 'angular-dimension :pass-down (character-size) :center-point (the center) :start-point (the p2) :end-point (the p3) :arrowhead-style :wedge :text-along-axis? t :dim-angle-precision 0 :suppress-decimal? t) (outside-part :type 'angular-dimension :pass-down (character-size) :center-point (the center) :start-point (the p4) :text-along-axis? t :end-point (the p3)) (big-angle :type 'angular-dimension :pass-down (character-size) :text-along-axis? t :center-point (the center) :start-point (the p4) :end-point (the p1) :dim-angle-style :degrees-minutes-seconds :leader-radius 1.5))) #+nil (defun ang () (with-format (pdf "/tmp/ang-try.pdf") (write-the-object (make-object 'angular-1) cad-output))) #+nil (defun ang-dxf () (with-format (dxf "/tmp/ang-try.dxf") (write-the-object (make-object 'angular-1) cad-output))) #+nil (define-object test-matrix (base-object) :input-slots ((length (half 792)) (width 612) (character-size 16) (leader-line-length (* (the character-size) 3)) (witness-line-length (the character-size)) (witness-line-ext (the witness-line-length)) (witness-line-gap (half (the witness-line-ext)))) :computed-slots ( ;;(ui-display-list-leaves (list-elements (the box-matrix))) ) :objects ( (rear-box :type 'box :display-controls (list :dxf-color-code 1) :length 700 :width 500 :center (translate (the center) :rear 450)) (hey-now :type 'general-note :display-controls (list :dxf-color-code 1) ;;:center (the rear-box center) :start (translate (the rear-box (vertex :rear :top :left)) :front (the-child character-size)) :character-size 50 ;;:font "Courier" :font "Helvetica" :orientation (alignment :rear (rotate-vector-d (the (face-normal-vector :rear)) 30 (the (face-normal-vector :top)))) :strings (list "hey now" "I'm Henk" "The quick brown" "fox jumps over" "the lazy dog" )) (box :type 'box :length 10 :width 10 :height 10) (hey :type 'general-note :strings "hey again" ) (vertical-dims :type 'vertical-dimension ;;:hidden? t :sequence (:matrix :lateral 2 :longitudinal 2) ;;:outline-shape-type :bubble :display-controls (list :dxf-color-code 1) :pass-down (leader-line-length character-size witness-line-length witness-line-ext witness-line-gap) :outside-leaders? (oddp (first (the-child index))) :text-above-leader? nil :start-point (the (box-matrix (first (the-child index)) (second (the-child index))) (vertex :rear :right :top)) :end-point (the (box-matrix (first (the-child index)) (second (the-child index))) (vertex :front :right :top)) ;;:start-point (if (oddp (second (the-child index))) ;;(the-child end-point-n) (the-child start-point-n)) ;;:end-point (if (oddp (second (the-child index))) ;;(the-child start-point-n) (the-child end-point-n)) ) (vertical-dims-flipped :type 'vertical-dimension ;;:hidden? t :display-controls (list :dxf-color-code 1) :sequence (:matrix :lateral 2 :longitudinal 2) :pass-down (leader-line-length character-size witness-line-length witness-line-ext witness-line-gap) :text-along-axis? t :outside-leaders? (oddp (first (the-child index))) :flip-leaders? t :start-point (if (oddp (second (the-child index))) (the-child end-point-n) (the-child start-point-n)) :end-point (if (oddp (second (the-child index))) (the-child start-point-n) (the-child end-point-n)) :start-point-n (the (box-matrix (first (the-child index)) (second (the-child index))) (vertex :rear :left :top)) :end-point-n (the (box-matrix (first (the-child index)) (second (the-child index))) (vertex :front :left :top))) (horizontal-dims :type 'horizontal-dimension ;;:hidden? t ;;:display-controls (list :dxf-color-code 1) :sequence (:matrix :lateral 2 :longitudinal 2) :pass-down (leader-line-length character-size witness-line-length witness-line-ext witness-line-gap) ;;:outline-shape-type :bubble :outside-leaders? (evenp (first (the-child index))) :text-above-leader? nil ;;:start-point (if (oddp (second (the-child index))) ;;(the-child end-point-n) (the-child start-point-n)) ;;:end-point (if (oddp (second (the-child index))) ;;(the-child start-point-n) (the-child end-point-n)) :start-point (the (box-matrix (first (the-child index)) (second (the-child index))) (vertex :rear :left :top)) :end-point (the (box-matrix (first (the-child index)) (second (the-child index))) (vertex :rear :right :top))) (horizontal-label :type 'label :pass-down (character-size) :strings "test label" :leader-path (list (the center) (translate (the center) :right 50) (translate (the center) :right 50 :rear 50))) (horizontal-dims-flipped :type 'horizontal-dimension ;;:display-controls (list :dxf-color-code 1) ;;:hidden? t :sequence (:matrix :lateral 2 :longitudinal 2) :pass-down (leader-line-length character-size witness-line-length witness-line-ext witness-line-gap) :outside-leaders? (evenp (first (the-child index))) :flip-leaders? t :start-point (if (oddp (second (the-child index))) (the-child end-point-n) (the-child start-point-n)) :end-point (if (oddp (second (the-child index))) (the-child start-point-n) (the-child end-point-n)) :start-point-n (the (box-matrix (first (the-child index)) (second (the-child index))) (vertex :front :left :top)) :end-point-n (the (box-matrix (first (the-child index)) (second (the-child index))) (vertex :front :right :top))) (box-matrix :type 'box ;;:display-controls (list :dxf-color-code 1) ;;:hidden? t :sequence (:matrix :lateral 2 :longitudinal 2) :length (/ (the length) 4) :width (/ (the width) 4) :quantify-box (the box-matrix-quant-box)) (box-matrix-quant-box :type 'box ;;:display-controls (list :dxf-color-code 1) ;;:hidden? t ) )) #+nil (defmethod draw ((format (eql 'dxf))) (with-format (dxf "/tmp/draw-try.dxf") (write-the-object (make-object 'busy-drawing) cad-output))) #+nil (defmethod draw ((format (eql 'pdf))) (with-format (pdf "/tmp/draw-try.pdf") (write-the-object (make-object 'busy-drawing) cad-output))) #+nil (defmethod draw ((format (eql 'png))) (with-format (png "/tmp/draw-try.png") (write-the-object (make-object 'busy-drawing) cad-output))) #+nil (define-object busy-drawing (base-drawing) :input-slots ((page-length 792) (page-width 612)) :objects ((large :type 'base-view :border-box? t ;;:left-margin 50 ;;:center (translate (the center) :left 50) :objects (the matrix children) ;;:objects (list (the matrix hey-now)) ) (matrix :type 'test-matrix)) :functions ((dxf () (with-format (dxf "/tmp/try.dxf") (write-the-object self cad-output))))) #+nil (define-object container (gwl:web-drawing) :computed-slots (;;(user-center (make-point 160 0 0)) (objects (list (the annotated-drawing)))) :objects ((annotated-drawing :type 'annotated-drawing))) #+nil (defun cont () (with-format (pdf "/tmp/cont-try.pdf") (write-the-object (make-object 'container) cad-output))) #+nil (defun contp () (with-format (png "/tmp/cont-try.png") (write-the-object (make-object 'container) cad-output))) #+nil (define-object annotated-drawing (base-drawing) :input-slots ((page-length 700) (page-width 800)) :objects ( (main-view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :width (* (the width) .95) :length (* (the length) .5) :center (translate (the center) :front (half (the-child length))) :objects (cons (the rear-box) (the box-matrix children)) :annotation-objects (list (the vertical-dim) (the horizontal-dim))) (top-view :type 'base-view :projection-vector (getf *standard-views* :top) :width (* (the width) .95) :length (* (the length) .5) :objects (cons (the rear-box) (the box-matrix children)) :center (translate (the center) :rear (half (the-child length))) ) (rear-box :type 'box :length (the box-matrix length) :width (the box-matrix width) :center (the box-matrix (face-center :rear))) (box-matrix :type 'box-matrix :length 300 :width 200) (angular-dim :type 'angular-dimension :character-size 15 :witness-line-length 30 :witness-line-ext 30 :witness-line-gap 10 :center-point (the main-view (view-point (the box-matrix (boxes 0 0) (vertex :front :left :top)))) :end-point (the main-view (view-point (the box-matrix (boxes 0 0) (vertex :rear :left :top)))) :start-point (the main-view (view-point (the box-matrix (boxes 0 0) (vertex :front :right :top))))) (horizontal-dim :type 'horizontal-dimension :start-point (the main-view (view-point (the box-matrix (boxes 0 0) (vertex :top :rear :left)))) :end-point (the main-view (view-point (the box-matrix (boxes 0 0) (vertex :top :rear :right)))) :witness-line-length 30 :witness-line-ext 30 :witness-line-gap 10 :dim-scale (/ (the main-view view-scale)) :character-size 10) (vertical-dim :type 'vertical-dimension :start-point (the main-view (view-point (the box-matrix (boxes 0 0) (vertex :top :front :right)))) :end-point (the main-view (view-point (the box-matrix (boxes 0 0) (vertex :top :rear :right)))) :witness-line-length 30 :witness-line-ext 30 :witness-line-gap 10 :leader-line-length 50 :dim-scale (/ (the main-view view-scale)) :outside-leaders? t :character-size 15))) #+nil (define-object box-matrix (base-object) :objects ((boxes :type 'box :sequence (:matrix :lateral 2 :longitudinal 2) :length (/ (the length) 4) :width (/ (the width) 4) :height 10 :display-controls (when (equalp (the-child index) (list 0 0)) (list :color :red)) :quantify-box (the boxes-quantify-box)) (boxes-quantify-box :type 'box :height 0))) #+nil (defmethod draw2 ((format (eql 'dxf))) (with-format (dxf "/tmp/draw2-try.dxf") (write-the-object (make-object 'annotated-drawing) cad-output))) #+nil (defmethod draw2 ((format (eql 'pdf))) (with-format (pdf "/tmp/draw2-try.pdf" :page-length 700 :page-width 800) (write-the-object (make-object 'annotated-drawing) cad-output))) #+nil (defmethod draw2 ((format (eql 'png))) (with-format (png "/tmp/draw2-try.png" :page-length 700 :page-width 800) (write-the-object (make-object 'annotated-drawing) cad-output))) #+nil (define-object robot-web (gwl:web-drawing) :input-slots ((page-length 700) (page-width 900)) :computed-slots ((projection-vector (getf *standard-views* :trimetric)) (object-roots (list (the robot robot)))) :objects ((robot :type 'robot:assembly))) #+nil (define-object robot-drawing (base-drawing) :input-slots ((page-length 792) (page-width 612)) :objects ((main-view :type 'base-view :fit-to-page? t :projection-vector (getf *standard-views* :top) :width (* (the width) .95) :length (* (the length) .95) :object-roots (list (the robot)) ) (robot :type 'robot:assembly))) #+nil (defmethod draw3 ((format (eql 'dxf))) (with-format (dxf "/tmp/draw3-try.dxf") (write-the-object (make-object 'robot-drawing) cad-output))) #+nil (defmethod draw3 ((format (eql 'pdf))) (let ((self (make-object 'robot-drawing))) (with-format (pdf "/tmp/draw3-try.pdf" :page-length (the page-length) :page-width (the page-width)) (write-the cad-output)))) #+nil (defmethod draw3 ((format (eql 'png))) (let ((self (make-object 'robot-drawing))) (with-format (png "/tmp/draw3-try.png") (write-the cad-output)))) #+nil (define-object box-with-drawing (base-object) :objects ((drawing :type 'dimensioned-drawing :objects (list (the box) (the length-dim))) (length-dim :type 'horizontal-dimension :start-point (the box (vertex :rear :top :left)) :end-point (the box (vertex :rear :top :right))) (box :type 'box :length 10 :width 20 :height 30))) #+nil (define-object dimensioned-drawing (base-drawing) :input-slots (objects) :objects ((main-view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :objects (the objects)))) #+nil (define-object box-with-two-viewed-drawing (base-object) :objects ((drawing :type 'two-viewed-drawing :objects (list (the box) (the length-dim))) (length-dim :type 'horizontal-dimension :start-point (the box (vertex :rear :top :left)) :end-point (the box (vertex :rear :top :right))) (box :type 'box :length 10 :width 20 :height 30))) #+nil (define-object two-viewed-drawing (base-drawing) :input-slots (objects) :objects ((main-view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :length (half (the length)) :center (translate (the center) :rear (half (the-child length))) :objects (the objects)) (top-view :type 'base-view :projection-vector (getf *standard-views* :top) :length (half (the length)) :center (translate (the center) :front (half (the-child length))) :objects (the objects)))) (define-object box-with-annotated-drawing (base-object) :objects ((drawing :type 'box-annotated-drawing :display-objects (list (the box) (the curve))) ;;(the curve) (curve :type 'b-spline-curve :control-points (list (make-point 0 0 0) (make-point 4 6.0 0.0) (make-point 8 4.0 0.0) (make-point 10 0.0 0.0) (make-point 8 -4.0 0.0) (make-point 4 -6.0 0.0) (make-point 0 0 0))) (box :type 'box :length 10 :width 20 :height 30))) (define-object box-annotated-drawing (base-drawing) :input-slots (display-objects (character-size 15) (witness-line-gap 10) (witness-line-length 15) (witness-line-ext 5)) :objects ((tri-view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :length (half (the length)) :center (translate (the center) :rear (half (the-child length))) :objects (the display-objects) :annotation-objects (list (the main-length-dim))) (main-length-dim :type 'vertical-dimension :pass-down (character-size witness-line-gap witness-line-length witness-line-ext) :start-point (the tri-view (view-point (the box (vertex :rear :top :right)))) :end-point (the tri-view (view-point (the box (vertex :rear :bottom :right)))) :dim-value (3d-distance (the box (vertex :rear :top :right)) (the box (vertex :rear :bottom :right))) :text-above-leader? nil) (front-view :type 'base-view :projection-vector (getf *standard-views* :front) :length (half (the length)) :center (translate (the center) :front (half (the-child length))) :objects (the display-objects) :annotation-objects (list (the top-length-dim))) (top-length-dim :type 'vertical-dimension :pass-down (character-size witness-line-gap witness-line-length witness-line-ext) :start-point (the front-view (view-point (the box (vertex :rear :top :right)))) :dim-scale (/ (the front-view view-scale)) :text-above-leader? nil :end-point (the front-view (view-point (the box (vertex :rear :bottom :right))))))) #+nil (define-object box-with-immune-dimension (base-object) :objects ((drawing :type 'immune-dimension-drawing :objects (list (the box))) (box :type 'box :length 10 :width 20 :height 30))) #+nil (define-object immune-dimension-drawing (base-drawing) :input-slots (objects (character-size 20) (witness-line-gap 10) (witness-line-length 15) (witness-line-ext 5)) :objects ((main-view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :objects (append (the objects) (list (the length-dim))) :immune-objects (list (the length-dim))) (length-dim :type 'horizontal-dimension :character-size (/ (the character-size) (the main-view view-scale)) :witness-line-gap (/ (the witness-line-gap) (the main-view view-scale)) :witness-line-length (/ (the witness-line-length) (the main-view view-scale)) :witness-line-ext (/ (the witness-line-ext) (the main-view view-scale)) :start-point (the box (vertex :rear :top :left)) :end-point (the box (vertex :rear :top :right)) )))
28,725
Common Lisp
.lisp
609
31.541872
106
0.51951
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
34df1ecd7df554b38e081c681987cdcdba8da2bacf32aace58c28b45710bd551
35,787
[ -1 ]
35,788
horizontal-dimension.lisp
lisp-mirror_gendl/geom-base/annotations/source/horizontal-dimension.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object horizontal-dimension (linear-dimension) :documentation (:description "Creates a dimension annotation along the horizontal axis." :examples "<pre> (in-package :gdl-user) (define-object box-view (base-object) :objects ((box :type 'box :length 10 :width (* (the-child length) +phi+) :height (* (the-child :width) +phi+)) (width-dimension :type 'horizontal-dimension :character-size (/ (the box length) 20) :arrowhead-width (/ (the-child character-size) 3) :start-point (the box (vertex :top :left :rear)) :end-point (the box (vertex :top :right :rear))))) (generate-sample-drawing :object-roots (make-object 'box-view)) </pre>") :input-slots ( (base-plane-normal (the (face-normal-vector :rear))) ("3D Point. Determines where the text will start. Defaults to reasonable location for horizontal-dimension." dim-text-start (let ((mid-point (translate-along-vector (the leader-start) (subtract-vectors (the leader-end) (the leader-start)) (half (3d-distance (the leader-start) (the leader-end)))))) (let ((center (cond ((and (not (the outside-leaders?)) (the text-above-leader?)) (translate mid-point :rear (* (half (the dimension-text length)) (the dim-text-above-gap-factor)))) ((not (the outside-leaders?)) ;;(translate mid-point :front (half (the dimension-text length))) mid-point ) (t (ecase (the dim-text-bias) (:center mid-point) (:start (translate (the leader-start) (if (the start-end-swapped?) :right :left) (+ (the leader-line-length) (half (the dimension-text width))))) (:end (translate (the leader-end) (if (the start-end-swapped?) :left :right) (+ (half (the dimension-text width)) (the leader-line-length-2))))))))) (translate center :left (half (the dimension-text width)) :front (half (the dimension-text length))))))) :computed-slots ( (sample-point-direction :right) (witness-direction-vector (the (face-normal-vector (if (the flip-leaders?) :front :rear)))) ;; ;; FLAG -- adjust for start-end-swapped? t ;; (leader-direction-1-vector (the (face-normal-vector (if (the start-end-swapped?) :right :left)))) (leader-direction-2-vector (the (face-normal-vector (if (the start-end-swapped?) :left :right)))) ))
4,453
Common Lisp
.lisp
77
37.948052
101
0.51004
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
38cc4a443344ba428b4685b03ac107c74bf9a140e7e9ac6499a4bc8666fd8bda
35,788
[ -1 ]
35,789
arrowhead.lisp
lisp-mirror_gendl/geom-base/annotations/source/arrowhead.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object arrowhead (base-object) :input-slots ((style :wedge) (length (* .2 72)) (width (* .1 72)) (wedge-ratio 1/3)) :computed-slots ((height 0) (arrow-center (translate (the center) :front (* (the length) (- 1 (the wedge-ratio))))) ;; ;; FLAG -- remove this when we have more general 2d bounding box machinery ;; (%lines-to-draw% (append (destructuring-bind (p0 p1 p2 p3) (the outline-points) (list (list p0 p1) (list p1 p2) (list p2 p3) (list p3 p0))) (when (the second-outline-points) (destructuring-bind (p0 p1 p2 p3) (the second-outline-points) (list (list p0 p1) (list p1 p2) (list p2 p3) (list p3 p0)))))) (path-info (append (list :move (first (the outline-points))) (mapcan #'(lambda(point) (list :line point)) (rest (the outline-points))))) (outline-points (ecase (the style) ((:wedge :double-wedge :triangle) (when (eql (the style) :triangle) (warn "*** ~%~%Triangle not yet supported~%~%")) (list (the center) (translate (the (vertex :front :right :top)) :front (half (the length))) (translate (the center) :front (* (the length) (- 1 (the wedge-ratio)))) (translate (the (vertex :front :left :top)) :front (half (the length))))))) (second-outline-points (when (member (the style) (list :double-wedge)) (mapcar #'(lambda(point) (translate point :front (* (the length) (- 1 (the wedge-ratio))))) (the outline-points)))))) ;; ;; FLAG -- update for auto-scaling outside base-view ;; (define-lens (pdf arrowhead)() :output-functions ((cad-output () (with-format-slots (view) (ecase (the style) ((:wedge :double-wedge :triangle) (pdf:with-saved-state (write-the line-thickness-setting) (destructuring-bind (p0 p1 p2 p3) (if view (mapcar #'(lambda(point) (the-object view (view-point point))) (the outline-points)) (the outline-points)) (write-the rgb-stroke-setting) (pdf:move-to (get-x p0) (get-y p0)) (pdf:line-to (get-x p1) (get-y p1)) (pdf:line-to (get-x p2) (get-y p2)) (pdf:line-to (get-x p3) (get-y p3)) (pdf:line-to (get-x p0) (get-y p0)) (pdf:fill-and-stroke)) (when (the second-outline-points) (destructuring-bind (p0 p1 p2 p3) (if view (mapcar #'(lambda(point) (the-object view (view-point point))) (the second-outline-points)) (the second-outline-points)) (write-the rgb-stroke-setting) (pdf:move-to (get-x p0) (get-y p0)) (pdf:line-to (get-x p1) (get-y p1)) (pdf:line-to (get-x p2) (get-y p2)) (pdf:line-to (get-x p3) (get-y p3)) (pdf:line-to (get-x p0) (get-y p0)) (pdf:fill-and-stroke)))))))))) (define-lens (dxf arrowhead)() :output-functions ((cad-output () (with-format-slots (view) (ecase (the style) ((:wedge :double-wedge :triangle) ;;(write-the line-thickness-setting) ;;(write-the rgb-stroke-setting) (let ((line-format-string " 0~%LINE~% 5~%~a~% 100~%AcDbEntity~% 100~%AcDbLine~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%")) (destructuring-bind (p0 p1 p2 p3) (mapcar #'(lambda(point) (add-vectors *dxf-translation* (subseq point 0 2))) (if view (mapcar #'(lambda(point) (the-object view (view-point point))) (the outline-points)) (the outline-points))) #+nil (format *stream* " 0~%LINE~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%" (get-x p0) (get-y p0) (get-x p1) (get-y p1)) (format *stream* line-format-string (incf *dxf-entity-id*) (get-x p0) (get-y p0) (get-x p1) (get-y p1)) (write-the line-thickness-setting) (write-the rgb-stroke-setting) #+nil (format *stream* " 0~%LINE~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%" (get-x p1) (get-y p1) (get-x p2) (get-y p2)) (format *stream* line-format-string (incf *dxf-entity-id*) (get-x p1) (get-y p1) (get-x p2) (get-y p2)) (write-the line-thickness-setting) (write-the rgb-stroke-setting) #+nil (format *stream* " 0~%LINE~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%" (get-x p2) (get-y p2) (get-x p3) (get-y p3)) (format *stream* line-format-string (incf *dxf-entity-id*) (get-x p2) (get-y p2) (get-x p3) (get-y p3)) (write-the line-thickness-setting) (write-the rgb-stroke-setting) #+nil (format *stream* " 0~%LINE~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%" (get-x p3) (get-y p3) (get-x p0) (get-y p0)) (format *stream* line-format-string (incf *dxf-entity-id*) (get-x p3) (get-y p3) (get-x p0) (get-y p0)) (write-the line-thickness-setting) (write-the rgb-stroke-setting)) (when (the second-outline-points) (destructuring-bind (p0 p1 p2 p3) (mapcar #'(lambda(point) (add-vectors *dxf-translation* (subseq point 0 2))) (if view (mapcar #'(lambda(point) (the-object view (view-point point))) (the second-outline-points)) (the second-outline-points))) (write-the line-thickness-setting) (write-the rgb-stroke-setting) #+nil (format *stream* " 0~%LINE~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%" (get-x p0) (get-y p0) (get-x p1) (get-y p1)) (format *stream* line-format-string (incf *dxf-entity-id*) (get-x p0) (get-y p0) (get-x p1) (get-y p1)) (write-the line-thickness-setting) (write-the rgb-stroke-setting) #+nil (format *stream* " 0~%LINE~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%" (get-x p1) (get-y p1) (get-x p2) (get-y p2)) (format *stream* line-format-string (incf *dxf-entity-id*) (get-x p1) (get-y p1) (get-x p2) (get-y p2)) (write-the line-thickness-setting) (write-the rgb-stroke-setting) #+nil (format *stream* " 0~%LINE~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%" (get-x p2) (get-y p2) (get-x p3) (get-y p3)) (format *stream* line-format-string (incf *dxf-entity-id*) (get-x p2) (get-y p2) (get-x p3) (get-y p3)) (write-the line-thickness-setting) (write-the rgb-stroke-setting) #+nil (format *stream* " 0~%LINE~% 10~%~3,16f~% 20~%~3,16f~% 11~%~3,16f~% 21~%~3,16f~%" (get-x p3) (get-y p3) (get-x p0) (get-y p0)) (format *stream* line-format-string (incf *dxf-entity-id*) (get-x p3) (get-y p3) (get-x p0) (get-y p0)) (write-the line-thickness-setting) (write-the rgb-stroke-setting))))))))))
8,763
Common Lisp
.lisp
184
35.11413
138
0.522075
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cbd418fd3efa495db166292f4aa77527f7b1ccef5dc924579cae0a2660ee2ac5
35,789
[ -1 ]
35,790
leader-line.lisp
lisp-mirror_gendl/geom-base/annotations/source/leader-line.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object leader-line (base-object) :documentation (:description "Creates a leader line with arrows on zero, one, or both ends") :input-slots ("List of 3D Points. Leader-line is rendered as a polyline going through these points." path-points ("List of two points or nil. The start and end of the break in the leader line to accomodate the dimension-text, in cases where there is overlap." break-points nil) ("Number. The width of the arrows. Defaults to (* (the line-thickness) 5)." arrowhead-width (* (the line-thickness) 5)) ("Number. The length of the arrows. Defaults to (* (the arrowhead-width) 2)" arrowhead-length (* (the arrowhead-width) 2)) ("Keyword. Controls the style of first arrowhead. Currently only :wedge is supported. Default is :wedge." arrowhead-style :wedge) ("Keyword. Controls the style and presence of second arrowhead. Currently only :wedge is supported. Default is :none." arrowhead-style-2 :none)) :computed-slots ((leader-vector (subtract-vectors (lastcar (the path-points)) (first (the path-points)))) (arrowhead-vector (subtract-vectors (second (the path-points)) (first (the path-points)))) (leader-length (3d-distance (first (the path-points)) (lastcar (the path-points)))) (path-info (append (the arrowhead path-info) (the polyline path-info) (apply #'append (mapsend (the polylines) :path-info)) (the arrowhead-2 path-info))) (display-controls (merge-display-controls (list :fill-color :black))) (%lines-to-draw% (remove nil (append (the polyline %lines-to-draw%) (apply #'append (mapsend (the polylines) :%lines-to-draw%)))))) :hidden-objects ((polyline :type (if (null (the break-points)) 'global-polyline 'null-part) :vertex-list (the path-points)) (polylines :type (if (the break-points) 'global-polyline 'null-part) :sequence (:size 2) :vertex-list (ecase (the-child index) (0 (list (first (the path-points)) (first (the break-points)))) (1 (list (second (the break-points)) (lastcar (the path-points)))) )) (arrowhead :type (if (not (eql (the arrowhead-style) :none)) 'arrowhead 'null-part) :center (first (the path-points)) :length (the arrowhead-length) :width (the arrowhead-width) :style (the arrowhead-style) :orientation (alignment :top (if (parallel-vectors? (the (face-normal-vector :top)) (the arrowhead-vector)) (the (face-normal-vector :rear)) (the (face-normal-vector :top))) :rear (reverse-vector (the arrowhead-vector)))) (arrowhead-2 :type (if (not (eql (the arrowhead-style-2) :none)) 'arrowhead 'null-part) :center (lastcar (the path-points)) :length (the arrowhead-length) :width (the arrowhead-width) :style (the arrowhead-style-2) :orientation (alignment :top (if (parallel-vectors? (the (face-normal-vector :top)) (the arrowhead-vector)) (the (face-normal-vector :rear)) (the (face-normal-vector :top))) :rear (the arrowhead-vector))))) ;; ;; FLAG -- update for auto-scaling outside base-view ;; (define-lens (2d-output leader-line)() :output-functions ((cad-output () (unless (typep (the polyline) 'null-part) (write-the polyline (cad-output))) (mapc #'(lambda(polyline) (unless (typep polyline 'null-part) (write-the-object polyline cad-output))) (list-elements (the polylines))) (write-the arrowhead (cad-output)) (write-the arrowhead-2 (cad-output)) )))
5,104
Common Lisp
.lisp
97
41.134021
109
0.618317
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6f53e34b7aa74604256e704b76cdb7e6abd68f1f5bbb48eff59a714f199fe699
35,790
[ -1 ]
35,791
issues.lisp
lisp-mirror_gendl/geom-base/annotations/source/issues.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gwl-user) (define-object display (application-mixin) :computed-slots ((ui-display-list-leaves (list (the ex-drawing)))) :objects ((ex-drawing :type 'ex-drawing-1))) (define-object ex-drawing-1 (base-drawing) :input-slots ((page-length 700) (page-width 800)) :objects ((top-view :type 'base-view :projection-vector (getf *standard-views* :top) :width (half (the page-width)) :objects (list (the box-1) (the box-2) (the box-3)) :annotation-objects (list (the dim-1) (the dim-2) (the dim-3)) :left-margin 30 :center (translate (the center) :left (half (the-child width)))) (detail-view :type 'base-view :projection-vector (getf *standard-views* :top) :width (/ (the width) 4) :length (/ (the length) 4) :objects (list (the box-3)) :annotation-objects (list (the dim-3a)) :front-margin 40 :center (translate (the center) :right (the-child width) :rear (the-child length))) (box-1 :type 'box :length 10 :width 10 :height 4 :center (make-point (half (the-child width)) (half (the-child length)) (half (the-child height)))) (box-2 :type 'box :length 5 :width 20 :height 20 :center (make-point (half (the-child width)) (+ (the box-1 length) (half (the-child length))) 0)) (box-3 :type 'box :length 2 :width 1 :height 1 :center (translate (the box-1 (face-center :right)) :left (half (the-child width)))) (dim-1 :type 'vertical-dimension :character-size 10 :dim-scale (/ (the top-view view-scale)) :dim-text (list "This is" "a multiline" "dim-text") :witness-line-length 1 :witness-line-gap 1 :start-point (the top-view (view-point (the box-1 (vertex :bottom :right :front)))) :end-point (the top-view (view-point (the box-2 (:vertex :bottom :right :front))))) (dim-2 :type 'vertical-dimension :character-size 10 :dim-scale (/ (the top-view view-scale)) :witness-line-length 10 :witness-line-gap 1 :text-along-axis? t :start-point (the top-view (view-point (the box-2 (vertex :bottom :right :rear)))) :end-point (the top-view (view-point (the box-2 (:vertex :bottom :right :front))))) (dim-3 :type 'vertical-dimension :character-size 10 :dim-scale (/ (the top-view view-scale)) :witness-line-length 15 :witness-line-gap 1 :outside-leaders? t :leader-line-length (* (the-child arrowhead-length) 3) :start-point (the top-view (view-point (the box-3 (vertex :bottom :right :rear)))) :end-point (the top-view (view-point (the box-3 (:vertex :bottom :right :front))))) (dim-3a :type 'vertical-dimension :character-size 10 :dim-scale (/ (the detail-view view-scale)) :witness-line-length 15 :witness-line-gap 1 :outside-leaders? t :leader-line-length (* (the-child arrowhead-length) 3) :start-point (the detail-view (view-point (the box-3 (vertex :bottom :right :rear)))) :end-point (the detail-view (view-point (the box-3 (:vertex :bottom :right :front)))))))
4,467
Common Lisp
.lisp
96
36.458333
109
0.590206
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
439708f3bcc62bba74cf9f06a87a077f026ce403dabed6115dbf2a3ca0bb3c54
35,791
[ -1 ]
35,792
leader-arc.lisp
lisp-mirror_gendl/geom-base/annotations/source/leader-arc.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object leader-arc (leader-line) :input-slots (center-point radius witness-direction-vector-1 witness-direction-vector-2) :hidden-objects ( (arc :type 'arc :center (the center-point) :pass-down (radius) :start-angle (angle-between-vectors (the (face-normal-vector :right)) (the witness-direction-vector-1) (the (face-normal-vector :top)) :-ve t) :end-angle (angle-between-vectors (the (face-normal-vector :right)) (the witness-direction-vector-2) (the (face-normal-vector :top)) :-ve t)) (arrowhead :type 'arrowhead :center (translate-along-vector (the center-point) (the witness-direction-vector-1) (the radius)) :length (the arrowhead-length) :width (the arrowhead-width) :style (the arrowhead-style) :orientation (alignment :top (the (face-normal-vector :top)) :rear (cross-vectors (the witness-direction-vector-1) (the (face-normal-vector :top))))) (arrowhead-2 :type (if (not (eql (the arrowhead-style-2) :none)) 'arrowhead 'null-part) :center (translate-along-vector (the center-point) (the witness-direction-vector-2) (the radius)) :length (the arrowhead-length) :width (the arrowhead-width) :style (the arrowhead-style-2) :orientation (alignment :top (the (face-normal-vector :top)) :rear (cross-vectors (the (face-normal-vector :top)) (the witness-direction-vector-2)))) (polyline :type 'null-part))) ;; ;; FLAG -- get rid of this specialized view for both leader-line and ;; leader-arc, and use outline-specialization-mixin instead. ;; ;; ;; FLAG -- update for auto-scaling outside base-view ;; (define-lens (2d-output leader-arc)() :output-functions ((cad-output () (write-the arc (cad-output)) (write-the arrowhead (cad-output)) (write-the arrowhead-2 (cad-output)))))
3,562
Common Lisp
.lisp
70
35.542857
97
0.557401
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ccd0971da46369bdab2dc2b579eafe994828b09600a815a41f116c8e06091cfe
35,792
[ -1 ]
35,793
small.lisp
lisp-mirror_gendl/geom-base/annotations/source/small.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object drawing-test (base-drawing) :input-slots (b-spline-surface paragraph view-width) :hidden-objects ((empty-view :type 'base-view :border-box? t) (paragraph-view :type 'base-view :border-box? t :length (the paragraph length) :width (the paragraph width) :corner (the surface-view (vertex :top :rear :right)) :front-margin 0 :left-margin 0 :objects (list (the paragraph))) (surface-view :type 'base-view :length 300 :width (the view-width) :border-box? t :projection-vector (getf *standard-views* :trimetric) :corner (the (vertex :top :rear :left)) :objects (list (the b-spline-surface))))) (define-object drawing-container (base-object) :input-slots ((view-width (half (the drawing width)))) :objects ((drawing :type 'drawing-test :pass-down (b-spline-surface paragraph view-width))) :hidden-objects ((paragraph :type 'ron-paul-text :width (the view-width)) (b-spline-surface :type 'surf::test-b-spline-surface))) (define-object ron-paul-text (typeset-block) :functions ((content () (typeset:compile-text () (typeset:paragraph (:font-size 26) (typeset:put-string "Congressman Ron Paul is the leading advocate for freedom in our nation's capital. As a member of the U.S. House of Representatives, Dr. Paul tirelessly works for limited constitutional government, low taxes, free markets, and a return to sound monetary policies. He is known among his congressional colleagues and his constituents for his consistent voting record. Dr. Paul never votes for legislation unless the proposed measure is expressly authorized by the Constitution. In the words of former Treasury Secretary William Simon, Dr. Paul is the one exception to the Gang of 535 on Capitol Hill.")))))) (define-object circle-drawing (base-drawing) :objects ((circle :type 'circle :radius 10 :center (make-point 0 0 0)) (main-view :type 'base-view :border-box? t :objects (list (the circle)))) :functions ((pdf-out () (with-format (pdf "/tmp/try.pdf") (write-the cad-output))) (dxf-out () (with-format (dxf "/tmp/try.dxf") (write-the cad-output)))))
3,545
Common Lisp
.lisp
83
33.771084
94
0.644504
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
643b640de24b6ca041bb4837ad00dfc3128b8299d077c2cf181d1611f6d28ee3
35,793
[ -1 ]
35,794
linear-dimension.lisp
lisp-mirror_gendl/geom-base/annotations/source/linear-dimension.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object linear-dimension (outline-specialization-mixin base-object) :documentation (:description "Creates a dimension along either the horizontal, vertical, or an arbitray axis. Use <tt>horizontal-dimension</tt>, <tt>vertical-dimension</tt>, or <tt>parallel-dimension</tt>, respectively, to achieve these.") :input-slots ( "Must be specified in the subclass except for angular" witness-direction-vector "Must be specified in the subclass except for angular" leader-direction-1-vector "Must be specified in the subclass except for angular" leader-direction-2-vector "Must be specified in the subclass except for angular" base-plane-normal ("Keyword symbol. Currently can be :bubble, :rectangle, or :none. Default is :none." outline-shape-type :none) ("GDL" underline? nil) "3D Point. Actual point where the dimension will start measuring" start-point "3D Point. Actual point where the dimension will stop measuring" end-point ("Keyword symbol, :left, :right, or :center. For multi-line dim-text, this justification is applied." justification :left) ("Boolean. Where applicable, determines whether text direction follows leader-line direction" text-along-axis? nil) (dim-scale 1) ("Number in Percentage. Adjusts the character width for DXF output. Defaults to the text-x-scale." dxf-text-x-scale (the text-x-scale)) ("Number. The scale factor for DXF character size vs PDF character size. Default is 0.8" dxf-size-ratio 0.8) ("String. This names the DXF font for this general-note. Defaults to <tt>(the font)</tt>." dxf-font (the font)) ("Number. The start of text will be offset by this amount for DXF output. Default is 2." dxf-offset 3) ("Number. 2D distance relative to the base-plane-normal. Can be over-ridden in the subclass" dim-value (* (3d-distance (inter-line-plane (inter-line-plane (the start-point) (the base-plane-normal) (the center) (the base-plane-normal)) (the (face-normal-vector :top)) (the center) (the (face-normal-vector :top))) (inter-line-plane (inter-line-plane (the end-point) (the base-plane-normal) (the center) (the base-plane-normal)) (the (face-normal-vector :top)) (the center) (the (face-normal-vector :top)))) (the dim-scale))) ("Boolean. Indicates whether to display a witness line coming off the <tt>start-point</tt>. Default is T" witness-line? t) ("Boolean. Indicates whether to display a witness line coming off the <tt>end-point</tt>. Default is T" witness-line-2? t) ("Number. Distance from the <tt>start-point</tt> and <tt>end-point</tt> to the start of each witness-line. Default is 0.1" witness-line-gap 0.1) ("Number. Distance the witness line(s) extend beyond the leader line. Default is 0.3" witness-line-ext 0.3) ("Boolean. Indicates whether the text is to the right or above the leader line, rather than in-line with it. Default is T." text-above-leader? t) ("Number. Amount of gap between leader lines and dimension text, when the dimension text is within the leader. Defaults to half the character-size." leader-text-gap (half (the character-size))) ("Number in Percentage. Adjusts the character width for the dimension-text and currently only applies only to PDF output" text-x-scale 100) ("Boolean. Indicates which direction the witness lines should take from the start and end points. The Default is NIL, which indicates :rear (i.e. ``up'') for <tt>horizontal-dimensions</tt> and :right for <tt>vertical-dimensions</tt>" flip-leaders? nil) ("Boolean. Indicates whether the leader line(s) should be inside or outside the interval between the start and end points. The default is NIL, which indicates that the leader line(s) should be inside the interval" outside-leaders? nil) ("Boolean. Indicates whether the first (or only) leader line should be displayed. The Default is T" leader-1? t) ("Boolean. Indicates whether the second leader line should be displayed. The Default is T" leader-2? t) ("Number. Indicates the length of the first leader for the case when <tt>outside-leaders?</tt> is non-NIL" leader-line-length (* (the arrowhead-length) (the outside-leaders-length-factor))) ("Number. Indicates the length of the full leader when <tt>outside-leaders?</tt> is nil. This defaults to nil, which indicates that the full-leader's length should be auto-computed based on the given start-point and end-point." full-leader-line-length nil) ("Number. Indicates the default length of the outside-leaders as a multiple of arrowhead-length. Defaults to 3." outside-leaders-length-factor 3) ("Number. Indicates the length of the second leader for the case when <tt>outside-leaders?</tt> is non-NIL" leader-line-length-2 (the leader-line-length)) ("Number. Length of the witness lines (or of the shorter witness line in case they are different lengths)" witness-line-length 1) ("Keyword Symbol. Style for arrowhead on end of <tt>leader-line</tt>. Currently supported values are <tt>:none</tt>, <tt>:wedge</tt> (the Default), and <tt>:double-wedge</tt>." arrowhead-style :wedge) ("Keyword Symbol. Style for arrowhead on end of <tt>leader-line</tt>. Currently supported values are <tt>:none</tt> (the Default), <tt>:wedge</tt>, and <tt>:double-wedge</tt>." arrowhead-style-2 (the arrowhead-style)) ("Width of arrowhead glyph. Defaults to half the character-size." arrowhead-width (half (the character-size))) ("Length (from tip to tail) of arrowhead glyph. Defaults to twice the <tt>arrowhead-width</tt>" arrowhead-length (* (the arrowhead-width) 2)) ("String naming a standard PDF font. Font for the label text. Defaults to \"Helvetica\"" font "Helvetica") ("Number. Size (glyph height) of the label text, in model units. Defaults to 1." character-size 1) ("GDL object or NIL. View object which will use this dimension. Defaults to NIL." view-reference-object nil) ("String. Determines the text which shows up as the dimension label. Defaults to the dim-value, which is computed specially in each specific dimension type." dim-text (format nil "~3,1,,,'0f" (the dim-value))) ("3D Vector (normally only 2D are used). The dim-text-start is offset by this vector, in model space. Defaults to #(0.0 0.0 0.0)" dim-text-start-offset (make-vector 0 0 0)) ("3D Point. Determines where the text will start. Defaults to halfway between start-point and end-point." dim-text-start (translate-along-vector (the start-point) (subtract-vectors (the end-point) (the start-point)) (half (3d-distance (the start-point) (the end-point))))) ("Keyword symbol, :start, :end, or :center. Indicates where to position the text in the case when <b>outside-leaders?</b> is non-nil. Defaults to :center" dim-text-bias :center) (dim-text-above-gap-factor 1.45) (orientation (when (the view-reference-object) (the view-reference-object orientation))) ) :computed-slots ( (%corners% (list (the start-point) (the end-point))) (safe-distance (+ (3d-distance (the start-point) (the center)) (3d-distance (the end-point) (the center)))) (safe-center (translate-along-vector (the center) (reverse-vector (the base-plane-normal)) (the safe-distance))) (start-base-distance (let ((intersect (inter-line-plane (the start-point) (the base-plane-normal) (the safe-center) (the base-plane-normal)))) (3d-distance (the start-point) intersect))) (end-base-distance (let ((intersect (inter-line-plane (the end-point) (the base-plane-normal) (the safe-center) (the base-plane-normal)))) (3d-distance (the end-point) intersect))) (witness-line-overages (let ((difference (- (the start-base-distance) (the end-base-distance)))) (if (the flip-leaders?) (if (plusp difference) (list :1 difference :2 0) (list :1 0 :2 (- difference))) (if (minusp difference) (list :1 (- difference) :2 0) (list :1 0 :2 difference))))) #+nil (witness-line-overages (let ((difference (- (the start-base-distance) (the end-base-distance)))) (if (the flip-leaders?) (if (plusp difference) (list :1 0 :2 (- difference)) (list :1 (- difference) :2 0)) (if (minusp difference) (list :1 (- difference) :2 0) (list :1 0 :2 difference))))) (witness-line-length-1 (+ (the witness-line-length) (getf (the witness-line-overages) :1))) (witness-line-length-2 (+ (the witness-line-length) (getf (the witness-line-overages) :2))) (start-end-swapped? (let ((sample-point (translate (the start-point) (the sample-point-direction) (3d-distance (the end-point) (the start-point))))) (not (in-halfspace? (the start-point) (subtract-vectors (the end-point) (the start-point)) sample-point (the end-point))))) (leader-start (translate-along-vector (the start-point) (the witness-direction-vector) (+ (the witness-line-length-1) (the witness-line-gap)))) (leader-end (let ((nominal (translate-along-vector (the end-point) (the witness-direction-vector) (+ (the witness-line-length-2) (the witness-line-gap))))) (if (and (not (the outside-leaders?)) (the full-leader-line-length)) (translate-along-vector (the leader-start) (subtract-vectors nominal (the leader-start)) (the full-leader-line-length)) nominal))) (full-leader-break-points (when *break-leaders?* (let ((points (list (first (the dimension-text (line-intersection-points (first (the full-leader path-points)) (the full-leader leader-vector)))) (first (the dimension-text (line-intersection-points (lastcar (the full-leader path-points)) (reverse-vector (the full-leader leader-vector)))))))) (when (and (first points) (second points) (between? (first points) (first (the full-leader path-points)) (lastcar (the full-leader path-points))) (between? (second points) (first (the full-leader path-points)) (lastcar (the full-leader path-points)))) (list (translate-along-vector (first points) (reverse-vector (the full-leader leader-vector)) (the leader-text-gap)) (translate-along-vector (second points) (the full-leader leader-vector) (the leader-text-gap)))))))) :hidden-objects ( ;;(start-cross :type 'point :center (the start-point) :display-controls (list :color :red)) ;;(end-cross :type 'point :center (the end-point) :display-controls (list :color :green)) (full-leader :type (if (not (the outside-leaders?)) 'leader-line 'null-part) :path-points (list (the leader-start) (the leader-end)) :break-points (the full-leader-break-points) :pass-down (arrowhead-style arrowhead-style-2 arrowhead-length arrowhead-width)) (leader-1 :type (if (and (the outside-leaders?) (the leader-1?)) 'leader-line 'null-part) :path-points (list (the leader-start) (translate-along-vector (the leader-start) (the leader-direction-1-vector) (the leader-line-length))) :pass-down (arrowhead-style arrowhead-length arrowhead-width) :arrowhead-style-2 :none) (leader-2 :type (if (and (the outside-leaders?) (the leader-2?)) 'leader-line 'null-part) :path-points (list (the leader-end) (translate-along-vector (the leader-end) (the leader-direction-2-vector) (the leader-line-length-2))) :pass-down (arrowhead-style arrowhead-length arrowhead-width) :arrowhead-style-2 :none) (witness-line-1 :type (if (the witness-line?) 'line 'null-part) :start (translate-along-vector (the start-point) (the witness-direction-vector) (the witness-line-gap)) :end (translate-along-vector (the-child start) (the witness-direction-vector) (+ (the witness-line-length-1) (the witness-line-ext)))) (witness-line-2 :type (if (the witness-line-2?) 'line 'null-part) :start (translate-along-vector (the end-point) (the witness-direction-vector) (the witness-line-gap)) :end (translate-along-vector (the-child start) (the witness-direction-vector) (+ (the witness-line-length-2) (the witness-line-ext)))) (dimension-text :type 'general-note :start (add-vectors (the dim-text-start) (the dim-text-start-offset)) :strings (ensure-list (the dim-text)) :orientation (if (the text-along-axis?) (alignment :top (the (face-normal-vector :top)) :right (subtract-vectors (the leader-end) (the leader-start))) (the orientation)) :pass-down (font character-size text-x-scale justification outline-shape-type underline? dxf-text-x-scale dxf-size-ratio dxf-font dxf-offset onclick-function))))
17,929
Common Lisp
.lisp
266
46.864662
126
0.551054
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2419e1d224ab2a844cbe7588ab688fb8979ff6be6e776b8f02efaabc933f0167
35,794
[ -1 ]
35,795
font-test.lisp
lisp-mirror_gendl/geom-base/annotations/source/font-test.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :gdl-user) (define-object font-drawing (base-drawing) :input-slots ((page-length 792) (page-width 612)) :hidden-objects ((main-view :type 'base-view :objects (the font-test children))) :hidden-objects ((font-test :type 'font-test)) :functions ((all () (the pdf) (the dxf)) (pdf () (with-format (pdf "/tmp/try.pdf") (write-the-object self cad-output))) (dxf () (with-format (dxf "/tmp/lazydog.dxf") (write-the-object self cad-output))))) (define-object font-test (base-object) :input-slots ((length (half 792)) (width 612) (character-size 50) (font "Courier")) :objects ((hey-now :type 'general-note :text-x-scale 150 :start (translate (the box (vertex :rear :top :left)) :front (the-child character-size)) :character-size (the character-size) :font (the font) :strings (list "hey now" "I'm Henk" "The quick brown" "fox jumps over" "the lazy dog" "mmmmmmmmmm" "llllllllll" "1111111111" "nnnnnnnnnn")) (grid-lines-h :type 'line :sequence (:size 5) :start (translate (the box (vertex :rear :top :left)) :front (* (the-child index) (/ (the box length) 5))) :end (translate (the-child start) :right (the box width))) (grid-lines-v :type 'line :sequence (:size 5) :start (translate (the box (vertex :rear :top :left)) :right (* (the-child index) (/ (the box width) 5))) :end (translate (the-child start) :front (the box length))) (box :type 'box :length 700 :width 500 :center (translate (the center) :rear 450)))) (defun all () (the-object (make-object 'font-drawing) all))
2,968
Common Lisp
.lisp
65
34.646154
88
0.575736
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
36d3f002f72f89eb89648f3676b20a0ef78d1cccc19e8835926b8e45a412b521
35,795
[ -1 ]
35,796
sample-drawing.lisp
lisp-mirror_gendl/geom-base/annotations/source/sample-drawing.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object sample-drawing (base-drawing) :documentation (:description "Defines a simple drawing with a single view for displaying objects or object-roots.") :input-slots ((objects nil) (object-roots nil) (projection-direction :top) (page-width 360) (page-length 360)) :objects ((main-view :type 'base-view :projection-vector (if (keywordp (the projection-direction)) (getf *standard-views* (the projection-direction)) (the projection-direction)) :objects (ensure-list (the objects)) :object-roots (ensure-list (the object-roots))))) (defun generate-sample-drawing (&key objects object-roots (format :pdf) (output-file (merge-pathnames "example.pdf" (glisp:temporary-folder))) projection-direction page-length page-width) (let ((init-args (append (when objects (list :objects objects)) (when object-roots (list :object-roots object-roots)) (when projection-direction (list :projection-direction projection-direction)) (when page-length (list :page-length page-length)) (when page-width (list :page-width page-width))))) (let ((self (apply #'make-object 'sample-drawing init-args))) (ecase format (:pdf (with-format (pdf output-file :page-length (the page-length) :page-width (the page-width)) (write-the cad-output))) (:png (with-format (png output-file :page-length (the page-length) :page-width (the page-width) :element-type '(unsigned-byte 8)) (write-the cad-output)))))))
2,878
Common Lisp
.lisp
53
41.264151
118
0.599714
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
21b027a6a821a0067dc8984f6ce1cecd0aedce9d64a4177006d539a3ae88eee8
35,796
[ -1 ]
35,797
center-line.lisp
lisp-mirror_gendl/geom-base/annotations/source/center-line.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :geom-base) (define-object center-line (outline-specialization-mixin base-object) :documentation (:description "Creates a dashed single centerline or crosshair centerline on a circle." :examples "<pre> (in-package :gdl-user) (define-object center-line-test (base-object) :objects ((circle-sample :type 'circle :display-controls (list :color :green) :center (make-point 10 10 10 ) :radius 10) (center-line-sample :type 'center-line :circle? t :center (the circle-sample center) :size (* 2.1 (the circle-sample radius))))) (generate-sample-drawing :objects (list (the-object (make-object 'center-line-test) circle-sample) (the-object (make-object 'center-line-test) center-line-sample)) :projection-direction (getf *standard-views* :top)) </pre>") :input-slots ("Number. The length of the centerline." size ("Boolean. Determines whether this will be a circle crosshair. Defaults to nil." circle? nil) ("Number. Distance between dashed line segments. Defaults to 0.1." gap-length 0.1 :defaulting) ("Number. Length of longer dashed line segments. Defaults to 1.0." long-segment-length 1 :defaulting) ("Number. Length of shorter dashed line segments. Defaults to 0.25." short-segment-length .25 :defaulting)) :trickle-down-slots (gap-length long-segment-length short-segment-length) :computed-slots ( (width (if (the circle?) (the size) 0)) (length (the size)) (height 0) (%lines-to-draw% (apply #'append (mapcar #'(lambda(object) (the-object object %lines-to-draw%)) (the outline-objects)))) (outline-objects (append (maptree (the crosshair) #'identity #'(lambda(obj) (the-object obj leaf?))) (maptree (the straight) #'identity #'(lambda(obj) (the-object obj leaf?)))))) :hidden-objects ((crosshair :type (if (the circle?) 'crosshair 'null-part) :pass-down (size)) (straight :type (if (the circle?) 'null-part 'segmented-line) :length (the size)))) (define-object crosshair (base-object) :input-slots (size) :objects ((vertical :type 'segmented-line :length (the size)) (horizontal :type 'segmented-line :orientation (alignment :right (the (face-normal-vector :rear))) :length (the size)))) (define-object segmented-line (base-object) :input-slots (length) :computed-slots ((remaining-length (half (- (the length) (+ (the short-segment-length) (the gap-length))))) (pitch (+ (the short-segment-length) (the long-segment-length) (twice (the gap-length)))) (short-long-pairs (floor (/ (the remaining-length) (the pitch)))) (pair-starts (let ((start (translate (the center) :rear (+ (the gap-length) (half (the short-segment-length))))) result) (dotimes (n (the short-long-pairs) (nreverse result)) (push start result) (setq start (translate start :rear (the pitch)))))) (rear-starts (mapcan #'(lambda(start) (list start (translate start :rear (+ (the short-segment-length) (the gap-length))))) (the pair-starts))) (rear-ends (let ((count -1)) (mapcar #'(lambda(start) (translate start :rear (if (oddp (incf count)) (the long-segment-length) (the short-segment-length)))) (the rear-starts)))) (last-point (or (lastcar (the rear-ends)) (the middle-line end))) (final-segment? (< (+ (the gap-length) (3d-distance (the last-point) (the center))) (half (the length)))) (final-start (when (the final-segment?) (list (translate (the last-point) :rear (the gap-length))))) (final-end (when (the final-segment?) (list (the (edge-center :rear :top))))) (starts (append (reverse (mapcar #'(lambda(point) (the (mirror-point point))) (append (the rear-starts) (the final-start)))) (append (the rear-starts) (the final-start)))) (ends (append (reverse (mapcar #'(lambda(point) (the (mirror-point point))) (append (the rear-ends) (the final-end)))) (append (the rear-ends) (the final-end))))) :objects ((middle-line :type 'line :start (translate (the center) :front (half (the short-segment-length))) :end (translate (the center) :rear (half (the short-segment-length)))) (extension-lines :type 'line :sequence (:size (length (the starts))) :start (nth (the-child index) (the starts)) :end (nth (the-child index) (the ends)))) :functions ((mirror-point (point) (let ((distance (3d-distance (the center) point)) (vector (subtract-vectors (the center) point))) (translate-along-vector point vector (twice distance))))))
8,418
Common Lisp
.lisp
143
34.27972
105
0.474912
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
bf2b294da363283ff83a16cd0d8e0b191f476acedad0a83cb267ed09e8605f2f
35,797
[ -1 ]
35,798
zzinit.lisp
lisp-mirror_gendl/surf/zzinit/source/zzinit.lisp
(in-package :surf) (defparameter *these-features* (list :surf)) (glisp:set-features *these-features*) (setq gdl::*features-to-initialize* (append gdl::*features-to-initialize* *these-features*))
197
Common Lisp
.lisp
4
47.75
92
0.753927
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
eb7512e13f41b0d7c51907d2207cf97b71b7e75819c8069fbce63cfae0f1700e
35,798
[ -1 ]
35,799
edge.lisp
lisp-mirror_gendl/surf/source/edge.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object edge (curve) :documentation (:description "Represents one edge in a brep. This object is a type of curve and answers all curve messages.") :input-slots (%native-edge% %native-brep% brep ) :computed-slots ((native-curve-iw (get-bspline-curve-from-edge *geometry-kernel* (the %native-edge%))) ("List of GDL Face objects. The faces connected to this edge." faces (let ((faces-ht (the brep faces-ht))) (mapcar #'(lambda(native-face) (gethash native-face faces-ht)) (the %native-faces%)))) (%native-faces% (get-faces-from-edge *geometry-kernel* (the %native-edge%))) (%unique-id% (get-long *geometry-kernel* self))) :functions (("GDL Curve object. This represents the UV curve for this edge on the given surface. Note that you have to pass in the surface, which should be the basis-surface of a face connected to this edge. The GDL edge object will be supplemented with a sequence of faces which are connected with this edge." uv-curve (surface) (make-object 'curve :native-curve-iw (get-uv-curve-from-edge *geometry-kernel* (the %native-edge%) (the-object surface native-surface-iw))))))
2,295
Common Lisp
.lisp
45
42.444444
127
0.717177
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3eddec5590eb629fa188239595da32f2b86ee574f2639e5265bf63144ae6425f
35,799
[ -1 ]
35,800
filleted-curve.lisp
lisp-mirror_gendl/surf/source/filleted-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) #| (Yes, the curves need to be planar ) 1. offset each curve by the given radius R 2. intersect the two offset curves for the center point C of the circle 3. project the center point back to each curve to get P1 at t1 on the first curve and P2 at t2 on the second curve 4. split each curve at t1 and t2 5. delete the ends of each curve 6. build the circular arc, center C, radius r from P1 to P2. |# (define-object filleted-curve (curve) :input-slots (segments default-radius (auto-chain? t) (plane-normal (the (face-normal-vector :top)))) :computed-slots ((chained-segments (if (the auto-chain?) (let ((segments (order-curves (the segments)))) (unless segments (error "In ~s (~s), segments were unable to be chained." self (the strings-for-display))) segments) (assert-ordered-curves (the segments)))) (closed? (coincident-point? (the-object (first (the chained-segments)) start) (the-object (lastcar (the chained-segments)) end))) (sharp-corners (let ((index -1) result) (mapcar #'(lambda(curve-1 curve-2) (incf index) (when (not (same-direction-vectors? (the-object curve-1 (tangent (the-object curve-1 u-max))) (the-object curve-2 (tangent (the-object curve-2 u-min))))) (push index result))) (the chained-segments) (if (the closed?) (append (rest (the chained-segments)) (list (first (the chained-segments)))) (rest (the chained-segments)))) (nreverse result))) (built-from (the fillets last composed)) (apparently-ok? (dolist (fillet (list-elements (the fillets)) t) (unless (the-object fillet apparently-ok?) (return nil))))) :objects ((fillets :type 'curve-fillet :sequence (:size (length (the sharp-corners))) :pass-down (plane-normal) :parent-curve self :radius (the default-radius) :segment-1 (cond ((the-child first?) (first (the chained-segments))) ((and (the closed?) (the-child last?)) (make-object 'trimmed-curve :built-from (the-child previous composed) :u1 (+ (the-child previous composed u1) (* 0.5 (- (the-child previous composed u2) (the-child previous composed u1)))))) (t (the-child previous composed))) :segment-2 (if (and (the (closed?)) (the-child last?)) (make-object 'trimmed-curve :built-from (the-child previous composed) :u2 (- (the-child previous composed u2) (* 0.5 (- (the-child previous composed u2) (the-child previous composed u1))))) (nth (if (< (the-child index) (length (the sharp-corners))) (1+ (nth (the-child index) (the sharp-corners))) 0) (the chained-segments)))))) (define-object curve-fillet (base-object) :input-slots (parent-curve radius segment-1 segment-2 plane-normal ) :computed-slots ((center (let ((intersects (the segment-1-offset (curve-intersection-points (the segment-2-offset))))) (get-3d-point-of (lastcar intersects)))) (apparently-ok? (and (the center) (> (get-parameter-of (the segment-1-drop)) (the segment-1 u1)) (< (get-parameter-of (the segment-2-drop)) (the segment-2 u2)))) (segment-1-drop (when (the center) (the segment-1 (dropped-point (the center))))) (segment-2-drop (when (the center) (the segment-2 (dropped-point (the center))))) (fillet-p1 (get-3d-point-of (the segment-1-drop))) (fillet-p2 (get-3d-point-of (the segment-2-drop))) (offset-direction (let ((angle (angle-between-vectors-d (reverse-vector (the segment-1 (tangent (the segment-1 u-max)))) (the segment-2 (tangent (the segment-2 u-min))) (the plane-normal)))) (if (< angle 180) :left :right)))) :objects ((fillet-arc :type 'arc-curve :pass-down (radius)) (segment-1-offset :type 'planar-offset-curve :curve-in (the segment-1) :distance (ecase (the offset-direction) (:right (the radius)) (:left (- (the radius)))) :pass-down (plane-normal)) (segment-2-offset :type 'planar-offset-curve :curve-in (the segment-2) :distance (the segment-1-offset distance) :pass-down (plane-normal)) (composed :type 'composed-curve :curves (list (the segment-1-trimmed) (the fillet) (the segment-2-trimmed))) (fillet :type 'arc-curve :pseudo-inputs (angle-1 angle-2 swap?) :pass-down (radius) :angle-1 (angle-between-vectors (the (face-normal-vector :right)) (subtract-vectors (the fillet-p1) (the center)) (the (face-normal-vector :top)) :-ve t) :angle-2 (angle-between-vectors (the (face-normal-vector :right)) (subtract-vectors (the fillet-p2) (the center)) (the (face-normal-vector :top)) :-ve t) :swap? (minusp (angle-between-vectors (subtract-vectors (the fillet-p2) (the center)) (subtract-vectors (the fillet-p1) (the center)) (the (:face-normal-vector :top)) :-ve t)) :start-angle (if (the-child swap?) (the-child angle-1) (the-child angle-2)) :end-angle (if (the-child swap?) (the-child angle-2) (the-child angle-1))) (segment-1-trimmed :type 'trimmed-curve :built-from (the segment-1) :u2 (let ((apparently-ok? (the apparently-ok?))) (unless apparently-ok? (error "Bummer! Filleting failed for ~s in ~s (~s). Center is ~s, segment-1 drop parameter is ~s, and segment-1 u1 is ~s." self (the parent-curve) (the parent-curve strings-for-display) (the center) (get-parameter-of (the segment-1-drop)) (the segment-1 u1))) (get-parameter-of (the segment-1-drop)))) (segment-2-trimmed :type 'trimmed-curve :built-from (the segment-2) :u1 (get-parameter-of (the segment-2-drop))))) ;; ;; The following is unsupported, for reference only for user code ;; ;; Derived from Corus filleted-curve-safe example. ;; (define-object filleted-curve-safe (curve) :input-slots (segments default-radius (auto-chain? t) (find-closest-radius? t) (step-increment 1) (step-max 25) (debug? nil)) :computed-slots ((built-from (the fillet)) (closest-radius (find-closest-radius (the default-radius) (the fillet segments) :step-increment (the step-increment) :step-max (the step-max) :debug? (the debug?))) (fillet-radius (if (the find-closest-radius?) (the closest-radius) (the default-radius)))) :objects ((fillet :type 'filleted-curve :pass-down (segments auto-chain?) :default-radius (the fillet-radius)))) (defun find-closest-radius (radius curves &key (step-increment 1) (step-max 25) (debug? nil)) ;; step-increment is percentage decrease in radius at each step ;; step-max is maximum percentage decrease in radius ;; debug? set to T prints debug output (when debug? (print-variables radius)) (do* ((i 0 (incf i)) (rad radius (* (div (- 100 (* i step-increment)) 100) radius)) (filleted (make-object 'filleted-curve :segments curves :default-radius rad) (make-object 'filleted-curve :segments curves :default-radius rad)) (apparently-ok? (the-object filleted apparently-ok?) (the-object filleted apparently-ok?))) ((or apparently-ok? (>= (* i step-increment) step-max)) (progn (print-variables rad) rad)) (when debug? (print-variables rad))))
11,145
Common Lisp
.lisp
177
40.892655
150
0.500564
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
df7cffc79b8ce29063d8b30b15729d1140b738abe822ccfa254c0278db94cc41
35,800
[ -1 ]
35,801
face.lisp
lisp-mirror_gendl/surf/source/face.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object face (surface) :documentation (:description "This object represents a (possibly) trimmed surface contained within a brep. It answers all the local messages of face, and it has surface mixed in as well, so it will answer all the surface messages. Note however that the local surface messages will operate on the basis, not on the trimmed representation. The messages for face will operate on the trimmed representation. This object is not meant for direct instantiation; rather, a brep will contain a quantified set of faces (called \"faces\"), and trimmed surface also mixes in face, so a trimmed-surface will answer all the face messages.") :input-slots (%native-face% %native-brep% ;; FLAG -- should default to get-brep-from-face of the %native-face%. "GDL Brep object. This is the brep object which contains this face object." brep ;; FLAG -- should default to a new brep constructed from the %native-brep% ("GDL NURBS Surface. The underlying surface, before any trimming takes place." basis-surface (the %extracted-basis%))) :computed-slots ( (outline-objects nil) (native-surface-iw (the %extracted-basis% native-surface-iw)) (%native-island-curves% (extract-face-island-curves *geometry-kernel* (the %native-face%))) (%native-hole-curves% (extract-face-hole-curves *geometry-kernel* (the %native-face%))) (%lines-to-draw% (progn (append (append-elements (the %reconstructed-trimmed-iso-curves%) (the-element %lines-to-draw%)) (append-elements (the %extracted-island%) (the-element %lines-to-draw%)) (apply #'append (mapcar #'(lambda(hole) (the-object hole %lines-to-draw%)) (list-elements (the %extracted-holes%))))))) (%curves-to-draw% (progn (append (append-elements (the %reconstructed-trimmed-iso-curves%) (the-element %curves-to-draw%)) (append-elements (the %extracted-island%) (the-element %curves-to-draw%)) (apply #'append (mapcar #'(lambda(hole) (the-object hole %curves-to-draw%)) (list-elements (the %extracted-holes%))))))) (bounding-box (the basis-surface bounding-box)) (u-iso-curves (the basis-surface u-iso-curves)) (v-iso-curves (the basis-surface v-iso-curves)) (%reconstructed-trimmed-iso-curves-native% (make-trimmed-iso-curves *geometry-kernel* (the %native-face%) *display-tolerance* (mapcar #'(lambda (curve) (make-b-spline-curve* *geometry-kernel* curve :schedule-finalization? t )) (append (list-elements (the u-iso-curves) (the-element native-curve)) (list-elements (the v-iso-curves) (the-element native-curve)))) nil)) (%native-edges% (get-edges-from-face *geometry-kernel* (the %native-face%))) (brep-id (the brep %unique-id%)) ) :hidden-objects ((%extracted-basis% :type 'surface :display-controls (when (the brep isos) (list :isos (the brep isos))) ;;(list :isos (list :n-u 8 :n-v 8)) :native-surface-iw (get-surface-from-face *geometry-kernel* (the %native-face%))) (%extracted-island% :type 'curve :sequence (:size (length (the %native-island-curves%))) :native-curve-iw (nth (the-child index) (the %native-island-curves%))) (%extracted-holes% :type 'native-curve-sequence :sequence (:size (length (the %native-hole-curves%))) :native-curves (nth (the-child index) (the %native-hole-curves%))) (%reconstructed-trimmed-iso-curves% :type 'curve :sequence (:size (length (the %reconstructed-trimmed-iso-curves-native%))) :native-curve-iw (nth (the-child index) (the %reconstructed-trimmed-iso-curves-native%))) ("Sequence of GDL Edge Objects. The Edges contained within this brep." edges :type 'edge :sequence (:size (length (the %native-edges%))) :brep (the brep) :%native-brep% (the %native-brep%) :%native-edge% (nth (the-child index) (the %native-edges%))) ) :functions ((trim-curves-to-face (curves) (make-trimmed-iso-curves *geometry-kernel* (the %native-face%) 0 curves nil)) ("Number. Returns the area of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" area (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (multiple-value-bind (area volume moments) (the (precise-properties :desired-accuracy desired-accuracy :face-thickness face-thickness)) (declare (ignore moments volume)) area)) ("Number. Returns the volume of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" volume (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (multiple-value-bind (area volume moments) (the (precise-properties :desired-accuracy desired-accuracy :face-thickness face-thickness)) (declare (ignore moments area)) volume)) ("Plist. Returns the moments of the face. The plist contains keys: :area-static-moments, :area-moments-of-inertia, :area-products-of-inertia, :area-second-moment-about-coordinate-axii, :volume-static-moments, :volume-moments-of-inertia, :volume-products-of-inertia, and :volume-second-moment-about-coordinate-axii. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" moments (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (multiple-value-bind (area volume moments) (the (precise-properties :desired-accuracy desired-accuracy :face-thickness face-thickness)) (declare (ignore area volume)) moments)) ("3D Vector (ie 3D Point). Returns the Area Static Moments of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" area-static-moments (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (getf (the (moments :desired-accuracy desired-accuracy :face-thickness face-thickness)) :area-static-moments)) ("3D Vector (ie 3D Point). Returns the Area Moments of Inertia of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" area-moments-of-inertia (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (getf (the (moments :desired-accuracy desired-accuracy :face-thickness face-thickness)) :area-moments-of-inertia)) ("3D Vector (ie 3D Point). Returns the Area Products of Inertia of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" area-products-of-inertia (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (getf (the (moments :desired-accuracy desired-accuracy :face-thickness face-thickness)) :area-products-of-inertia)) ("3D Vector (ie 3D Point). Returns the Area Second Moment About Coordinate Axii of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" area-second-moment-about-coordinate-axii (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (getf (the (moments :desired-accuracy desired-accuracy :face-thickness face-thickness)) :area-second-moment-about-coordinate-axii)) ("3D Vector (ie 3D Point). Returns the Volume Static Moments of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" volume-static-moments (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (getf (the (moments :desired-accuracy desired-accuracy :face-thickness face-thickness)) :volume-static-moments)) ("3D Vector (ie 3D Point). Returns the Volume Moments of Inertia of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" volume-moments-of-inertia (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (getf (the (moments :desired-accuracy desired-accuracy :face-thickness face-thickness)) :volume-moments-of-inertia)) ("3D Vector (ie 3D Point). Returns the Volume Products of Inertia of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" volume-products-of-inertia (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (getf (the (moments :desired-accuracy desired-accuracy :face-thickness face-thickness)) :volume-products-of-inertia)) ("3D Vector (ie 3D Point). Returns the Volume Second Moment about Coordinate Axii of the face. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness.\")" volume-second-moment-about-coordinate-axii (&key (desired-accuracy 0.000001) (face-thickness 0.0)) (getf (the (moments :desired-accuracy desired-accuracy :face-thickness face-thickness)) :volume-second-moment-about-coordinate-axii)) ("Multiple values: Number, Number, and Plist. Returns the area, volume, and moments of the face. The moments are labeled as: :area-static-moments, :area-moments-of-inertia, :area-products-of-inertia, :area-second-moment-about-coordinate-axii, :volume-static-moments, :volume-moments-of-inertia, :volume-products-of-inertia, and :volume-second-moment-about-coordinate-axii. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\" (face-thickness 0.0) \"Number. Optional thickness of the trimmed surface.\")" precise-properties (&key (desired-accuracy 0.000001) (origin (make-point 0 0 0)) (estimated-area 0.0) (face-thickness 0.0)) (face-compute-precise-properties *geometry-kernel* (the %native-face%) desired-accuracy origin estimated-area face-thickness)))) (define-object native-curve-sequence (base-object) :input-slots (native-curves) :computed-slots ((curve-segments (list-elements (the curves))) (%curves-to-draw% (append-elements (the curves) (the-element %curves-to-draw%)))) :objects ((curves :type 'curve :sequence (:size (length (the native-curves))) :native-curve-iw (nth (the-child index) (the native-curves)))))
12,986
Common Lisp
.lisp
181
60.535912
321
0.668761
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0e444046e2a7973ca02dc54a9339a7131c45c6c3942b41273ced3c37a5c8b464
35,801
[ -1 ]
35,802
grouped-items.lisp
lisp-mirror_gendl/surf/source/grouped-items.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object grouped-items (geometry-kernel-object-mixin base-object) :input-slots (items) :computed-slots ( (%lines-to-draw% (apply #'append (mapsend (the items) :%lines-to-draw%))) (%curves-to-draw% (apply #'append (mapsend (chain-nurbs-curves (the items)) :%curves-to-draw%))))) (eval-when (compile load eval) (export 'grouped-items))
1,254
Common Lisp
.lisp
28
41.678571
102
0.727273
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2130fee62537b3eb821e1f1c4a29beaeff64dca8fa60e8cee0310e701aa9442b
35,802
[ -1 ]
35,803
transformed-solid.lisp
lisp-mirror_gendl/surf/source/transformed-solid.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object transformed-solid (brep) :documentation (:description "This primitive Translates, Orients, and optionally Scales a brep solid into another brep solid.") :input-slots ("GDL Brep Object. Source Brep to be copied and transformed." brep ("GDL Object. Reference Object for from-location and from-orientation. Defaults to the given brep." from-object (the brep)) ("3D Point. Reference location from which to translate. Defaults to the from-object center." from-location (the from-object center)) ("3D Point. Reference location to which to translate. Defaults to the from-object center." to-location (the from-object center)) ("3x3 Orientation Matrix or nil. Defaults to the from-object's orientation." from-orientation (the from-object orientation)) ("3x3 Orientation Matrix or nil. Target orientation relative to the from-orientation. Defaults to nil." to-orientation nil) ("3D Vector or nil. Scale to be applied before transform in each axis, or nil if no scale to be applied." scale nil) ("Boolean. Controls whether to do the shrink cleanup step after the tranform. Defaults to nil." sew-and-orient? nil) ("Boolean. Controls whether to do the shrink cleanup step after the tranform. Defaults to nil." shrink? nil) ) :computed-slots ((transform-vector (subtract-vectors (the to-location) (the from-location))) (transform-matrix (let ((no-transform? (and (null (the to-orientation)) (null (the from-orientation))))) (if no-transform? geom-base::+identity-3x3+ (matrix:multiply-matrix (or (the to-orientation) geom-base::+identity-3x3+) (matrix:transpose-matrix (or (the from-orientation) geom-base::+identity-3x3+)))))) (%native-brep% (make-transformed-brep *geometry-kernel* (the brep) :translation (the transform-vector) :x-vector (the coordinate-base (face-normal-vector :right)) :y-vector (the coordinate-base (face-normal-vector :rear)) :sew-and-orient? (the sew-and-orient?) :shrink? (the shrink?) :scale-vector (the scale)))) :hidden-objects ((coordinate-base :type 'base-object :orientation (the transform-matrix))))
3,888
Common Lisp
.lisp
57
49.701754
133
0.604535
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4efdc89970206281349e0b81b6462bf088deb90ac3d250689dd7ccba41e98314
35,803
[ -1 ]
35,804
box-intersection.lisp
lisp-mirror_gendl/surf/source/box-intersection.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (defun line-intersection (n) (let ((x1 (first n)) (y1 (second n)) (x2 (third n)) (y2 (fourth n)) (x3 (fifth n)) (y3 (sixth n)) (x4 (seventh n)) (y4 (eighth n))) (let ((denom (- (* (- y4 y3) (- x2 x1)) (* (- x4 x3) (- y2 y1)))) (ua-num (- (* (- x4 x3) (- y1 y3)) (* (- y4 y3) (- x1 x3)))) (ub-num (- (* (- x2 x1) (- y1 y3)) (* (- y2 y1) (- x1 x3)))) (dif-x-1 (- x1 x2)) (dif-y-1 (- y1 y2)) (dif-x-2 (- x3 x4)) (dif-y-2 (- y3 y4)) ) (cond ;; If the line is a point this can happen in 2D projection of 3D line ((and (zerop dif-x-1) (zerop dif-y-1)) nil) ((and (zerop dif-x-2) (zerop dif-y-2)) nil) ;; If the denominator and numerator for the equations for ua and ;; ub are 0 then the two lines are coincident. ;;((and (zerop denom) (zerop ua-num) (zerop ub-num)) (list x1 y1));;;?????? this condition is not 100% true ????? ;; If the denominator for the equations for ua and ub is 0 then ;; the two lines are parallel. ((zerop denom) nil) (t (let ((ua (/ ua-num denom)) (ub (/ ub-num denom))) (if (and (<= 0 ua 1) (<= 0 ub 1)) (list (+ x1 (* ua (- x2 x1))) (+ y1 (* ua (- y2 y1)))) nil))))))) (defun get-box-corners (bounding-box) (let ((min-y-1 (list (get-x (first bounding-box)) (get-y (first bounding-box)) (get-z (first bounding-box)))) (max-y-3 (list (get-x (second bounding-box)) (get-y (second bounding-box)) (get-z (second bounding-box))))) (let ((min-y-2 (list (first max-y-3) (second min-y-1) (third min-y-1))) (min-y-3 (list (first max-y-3) (second min-y-1) (third max-y-3))) (min-y-4 (list (first min-y-1) (second min-y-1) (third max-y-3))) (max-y-1 (list (first min-y-1) (second max-y-3) (third min-y-1))) (max-y-2 (list (first max-y-3) (second max-y-3) (third min-y-1))) (max-y-4 (list (first min-y-1) (second max-y-3) (third max-y-3)))) (list (list min-y-1 min-y-2 min-y-3 min-y-4) (list max-y-1 max-y-2 max-y-3 max-y-4))))) (defun get-polygon-edges (points) ;;This converts the points, which specifies a polygon, in a list of lines defined by (X1 Y1) (X2 Y2)" (let ((start (car (last points)))) (loop for point in points collect (list start point) do (setf start point )))) (defun get-box-edges (bounding-box) (append (get-polygon-edges (first (get-box-corners bounding-box))) (mapcan #'(lambda (min max)(list (list min max))) (first (get-box-corners bounding-box)) (second (get-box-corners bounding-box))) (get-polygon-edges (second (get-box-corners bounding-box))))) (defun get-xy-boxs-intersection (bounding-box-1 bounding-box-2) (remove nil (mapcar #'(lambda (line) (remove nil (loop for i in (get-box-edges bounding-box-1) collect (line-intersection (list (first (first line ))(second (first line ))(first (second line ))(second (second line )) (first (first i ))(second (first i))(first (second i))(second (second i))))))) (get-box-edges bounding-box-2)))) (defun get-xz-boxs-intersection (bounding-box-1 bounding-box-2) (remove nil (mapcar #'(lambda (line) (remove nil (loop for i in (get-box-edges bounding-box-1) collect (line-intersection (list (first (first line ))(third (first line ))(first (second line ))(third (second line )) (first (first i ))(third (first i))(first (second i))(third (second i))))))) (get-box-edges bounding-box-2)))) (defun get-yz-boxs-intersection (bounding-box-1 bounding-box-2) (remove nil (mapcar #'(lambda (line) (remove nil (loop for i in (get-box-edges bounding-box-1) collect (line-intersection (list (second (first line ))(third (first line ))(second (second line ))(third (second line )) (second (first i ))(third (first i))(second (second i))(third (second i))))))) (get-box-edges bounding-box-2)))) (defun box-intersection (bounding-box-1 bounding-box-2) (let (( xyz-intersection (length (remove nil (list (get-xy-boxs-intersection bounding-box-1 bounding-box-2) (get-xz-boxs-intersection bounding-box-1 bounding-box-2) (get-yz-boxs-intersection bounding-box-1 bounding-box-2)))))) (if (cond (( = 3 xyz-intersection) t)) t nil))) (define-object box-intersection-test (base-object) :input-slots ((x-factor 0 :settable) (y-factor 0 :settable) (z-factor 0 :settable)) :computed-slots ((surf-1-surf-2-intersect? (the surface-1 brep (brep-intersect? (the surface-2 brep))))) :objects ((curve-1 :type 'b-spline-curve :hidden? t :degree 2 :control-points (list #(1.0 0.0 0.0) #(1.0 0.5 0.5) #(1.0 1.0 0.0))) (curve-2 :type 'linear-curve :hidden? t :start #(0.0 0.0 0.0) :end #(0.0 1.0 0.0)) (curve-11 :type 'b-spline-curve :hidden? t :degree 2 :control-points (list (make-point (+ (the x-factor) 0.0) (+ (the y-factor) 0.0) (+ (the z-factor) 0.0)) (make-point (+ (the x-factor) 0.0) (+ (the y-factor) 0.5) (+ (the z-factor) 0.5)) (make-point (+ (the x-factor) 0.0) (+ (the y-factor) 1.0) (+ (the z-factor) 0.0)))) (curve-22 :type 'linear-curve :hidden? t :start (make-point (+ (the x-factor) 1.0) (+ (the y-factor) 0.0) (+ (the z-factor) 0.0)) :end (make-point (+ (the x-factor) 1.0) (+ (the y-factor) 1.0) (+ (the z-factor) 0.0))) (surface-1 :type 'ruled-surface :display-controls (list :color :red) :curve-1 (the curve-1) :curve-2 (the curve-2)) (surface-2 :type 'ruled-surface :display-controls (list :color :green) :curve-1 (the curve-11) :curve-2 (the curve-22)) (message :type 'general-note :start (make-point 3 0 0) :character-size 0.1 :display-controls (list :color :yellow) :strings (format nil "box-intersection-message ~a" (box-intersection (the surface-1 bounding-box) (the surface-2 bounding-box)))) ;; ;; This was previously using surface-1 and surface-1, was that a typo? ;; (test-brep-intersect :type 'brep-intersect :brep (the surface-1 brep) :other-brep (the surface-2 brep))))
9,373
Common Lisp
.lisp
188
33.31383
134
0.467186
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ad2e4a8f757bb7cbffb8c71d8947b729be4fca24b8d90f4aa232e5b5a66d9a1d
35,804
[ -1 ]
35,805
gordon-surface.lisp
lisp-mirror_gendl/surf/source/gordon-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) ;; ;; FLAG -- get rid of raw smlib calls in here. ;; #+nil (define-object gordon-surface (surface) :documentation (:description "Creates a Gordon surface. It creates a Gordon surface interpolating two sets of compatible NON-RATIONAL curves. More precisely, given C_i(u) at v[i], i=0,...,k, and C_j(v) at u[j], j= 0,...,l." :examples "<pre> </pre>" ) :input-slots (u-curves u-degree u-degree-tensor u-parameters v-curves v-degree v-degree-tensor v-parameters) :computed-slots ((native-surface (smlib::make-gordon-surface *geometry-kernel* (mapsend (the u-curves) :copy-new) (mapsend (the v-curves) :copy-new) (the u-parameters) (the v-parameters) (the u-degree) (the v-degree) (the u-degree-tensor) (the v-degree-tensor))))) #+nil (define-object gordon-surface-with-direct-parameters (surface) :documentation (:description "Creates a Gordon surface. It creates a Gordon surface interpolating two sets of compatible NON-RATIONAL curves. More precisely, given C_i(u) at v[i], i=0,...,k, and C_j(v) at u[j], j= 0,...,l." :examples "<pre> </pre>" ) :input-slots (u-curves u-degree u-degree-tensor u-parameters v-curves v-degree v-degree-tensor v-parameters) :computed-slots ((native-surface (smlib::gordon-surf-with-direct-parameters *geometry-kernel* (the u-curves) (the v-curves) (the u-parameters) (the v-parameters) (the u-degree) (the v-degree) (the u-degree-tensor) (the v-degree-tensor))))) #+nil (define-object test-gordon-surface (base-object) :computed-slots ((u-curves (list (the curve-u-min ) (the curve-u-0.25 ) (the curve-u-0.50 ) (the curve-u-max ))) (v-curves (list (the curve-v-min ) (the curve-v-0.25 ) (the curve-v-0.50 ) (the curve-v-max ))) (u-parameters (list '(0.0 0.25 0.5 1.0) '(0.0 0.25 0.5 1.0) '(0.0 0.25 0.5 1.0) '(0.0 0.25 0.5 1.0))) (v-parameters (list '(0.0 0.25 0.5 1.0) '(0.0 0.25 0.5 1.0) '(0.0 0.25 0.5 1.0) '(0.0 0.25 0.5 1.0))) (u-degree (the surface u-degree)) (v-degree (the surface v-degree)) (u-degree-tensor (the surface u-degree)) (v-degree-tensor (the surface v-degree)) ;; ;;for gordon-surface-with-direct-parameters ;; (u '(0.0 0.25 0.5 1.0)) (v '(0.0 0.25 0.5 1.0))) :objects ((curve-1 :type 'b-spline-curve :degree 3 :control-points (list (make-point 0 0 0) (make-point 3 2 0) (make-point 5 1 0) (make-point 7 2 0) (make-point 9 0 0))) (curve-2 :type 'b-spline-curve :degree 3 :control-points (list (make-point 0 0 1) (make-point 3 1 1) (make-point 5 1 1) (make-point 7 2 1) (make-point 9 0 1))) (curve-3 :type 'b-spline-curve :degree 3 :control-points (list (make-point 0 0 2) (make-point 3 2 2) (make-point 5 1 2) (make-point 7 1 2) (make-point 9 0 2))) (curve-4 :type 'b-spline-curve :degree 3 :control-points (list (make-point 0 0 4) (make-point 3 2 4) (make-point 5 1 4) (make-point 7 2 4) (make-point 9 0 4))) (surface :type 'lofted-surface :v-degree 3 :curves (list (the curve-1)(the curve-2)(the curve-3)(the curve-4))) (curve-u-min :type 'iso-curve :parameter 0.0 :surface (the surface) :u-or-v :u) (curve-u-0.25 :type 'iso-curve :parameter 0.25 :surface (the surface) :u-or-v :u) (curve-u-0.50 :type 'iso-curve :parameter 0.5 :surface (the surface) :u-or-v :u) (curve-u-max :type 'iso-curve :parameter 1.0 :surface (the surface) :u-or-v :u) (curve-v-min :type 'iso-curve :parameter 0.0 :surface (the surface) :u-or-v :v) (curve-v-0.25 :type 'iso-curve :parameter 0.25 :surface (the surface) :u-or-v :v) (curve-v-0.50 :type 'iso-curve :parameter 0.5 :surface (the surface) :u-or-v :v) (curve-v-max :type 'iso-curve :parameter 1.0 :surface (the surface) :u-or-v :v) ;;!!!!!!! (test-gordon-s :type 'gordon-surface :u-curves (the u-curves) :v-curves (the v-curves) :u-parameters (the u-parameters) :v-parameters (the v-parameters) :u-degree (the u-degree) :v-degree (the v-degree) :u-degree-tensor (the u-degree-tensor) :v-degree-tensor (the v-degree-tensor)) ;;!!!!!!! (test-gordon-s-d :type 'gordon-surface-with-direct-parameters :u-curves (the u-curves) :v-curves (the v-curves) :u-parameters (the u) :v-parameters (the v) :u-degree (the u-degree) :v-degree (the v-degree) :u-degree-tensor (the u-degree-tensor) :v-degree-tensor (the v-degree-tensor))))
8,086
Common Lisp
.lisp
163
29.650307
226
0.440041
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a07ae4b34c696b0d96f4f6e65d325177ea0c831a745e6a1681c7c0b72235444c
35,805
[ -1 ]
35,806
coons-surface.lisp
lisp-mirror_gendl/surf/source/coons-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object coons-surface (surface) :input-slots (curve-left curve-right curve-bottom curve-top derivative-left derivative-right derivative-bottom derivative-top) :computed-slots ((native-surface (make-coons-patch *geometry-kernel* :curve-left (the curve-left) :curve-right (the curve-right) :curve-bottom (the curve-bottom) :curve-top (the curve-top) :derivative-left (the derivative-left) :derivative-right (the derivative-right) :derivative-bottom (the derivative-bottom) :derivative-top (the derivative-top)))))
1,756
Common Lisp
.lisp
41
32.512195
80
0.613623
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
ab78c23dd6c3362e79c3b51cef76cc0aee748795b0ef7cabecbb614596d24c67
35,806
[ -1 ]
35,807
extended-curve.lisp
lisp-mirror_gendl/surf/source/extended-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object extended-curve (curve) :documentation (:description "Creates an extended curve extending its start or end (<tt>u1</tt> and <tt>u2</tt>)." :examples "<pre> (in-package :gdl-user) (define-object test-extended-curve () :objects ((b-spline-curve :type 'b-spline-curve :display-controls (list :color :black :line-thickness 3.0) :control-points (list (make-point -2.0 0.0 0.0) (make-point 0.0 1.0 0.0) (make-point 1.0 0.0 0.0) (make-point 0.0 -1.0 0.0))) (extended-curve-G1 :type 'extended-curve :curve-in (the b-spline-curve) :distance 2.5 :distance-type :absolute :extending-from :start :continuity :g1 :display-controls (list :color :red)) (extended-curve-G2 :type 'extended-curve :curve-in (the b-spline-curve) :distance 2.5 :distance-type :absolute :extending-from :start :continuity :g2 :display-controls (list :color :green)) (extended-curve-Cmax :type 'extended-curve :curve-in (the b-spline-curve) :distance 2.5 :distance-type :absolute :extending-from :start :continuity :cmax :display-controls (list :color :blue)))) (generate-sample-drawing :object-roots (make-object 'test-extended-curve)) </pre>" ) :input-slots ("GDL Curve Object. The underlying curve from which to build this curve." curve-in ("Number. Specified the distance to which the curve is extended." distance) ("Keyword. Specified if the distance is an absolute distance <tt>:absolute</tt> or the distance is scaled by the curve's arc length to yield the desired extension distance <tt>:relative</tt>. Defaults to the <tt>:absolute</tt>." distance-type :absolute) ("Keyword. Specified from which end the curve to be extended. If :start the curve is extended back from its start point. If :end the the curve is extended forward from its end point. Defaults to the <tt>:start</tt>." extending-from :start) ("Keyword. Specified the extention continuity. If :g1 the curve is extended by a linear segment. Curve-in is at least G1(possibly C1) where the extension joins the original curve. If :g2 the curve is extended by reflection, yielding a G2 continuous extension. If :cmax the extension yields infinite(C) continuity at the join point(no knot there). Defaults to the <tt>:g2</tt>." continuity :g2) ) :computed-slots ((native-curve (make-extend-curve *geometry-kernel* (the curve-in) :distance (the distance) :distance-type (the distance-type) :extending-from (the extending-from) :continuity (the continuity))))) (define-object test-extended-curve () :objects ((b-spline-curve :type 'arc-curve :center (make-point 0 0 0) :radius 1.5 :start-angle 0 :end-angle pi) (extended-curve-G1 :type 'extended-curve :curve-in (the b-spline-curve) :distance 3.0 :distance-type :absolute :extending-from :start :continuity :g1 :display-controls (list :color :red)) (extended-curve-G2 :type 'extended-curve :curve-in (the b-spline-curve) :distance 2.5 :distance-type :absolute :extending-from :start :continuity :g2 :display-controls (list :color :green)) (extended-curve-Cmax :type 'extended-curve :curve-in (the b-spline-curve) :distance 3.0 :distance-type :absolute :extending-from :start :continuity :cmax :display-controls (list :color :blue))))
5,716
Common Lisp
.lisp
105
36.961905
139
0.548548
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e4749ad2d1b13ab89d69ba5688ee0e8d67bdf461f612fbd69ad742a8b1bae569
35,807
[ -1 ]
35,808
circular-surface.lisp
lisp-mirror_gendl/surf/source/circular-surface.lisp
;; ;; Copyright 2015 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object circular-surface (trimmed-surface) :documentation (:description "Represents a planar, full-circular surface controlled by a radius, and the normal center and orientation for base-object." :examples "<pre> (in-package :gdl-user) (define-object circular-surface-test (surf::circular-surface) :computed-slots ((radius 108))) (generate-sample-drawing :objects (make-object 'circular-surface-test)) </pre>") :input-slots ("Number. The radius of the resulting trimmed-surface." radius) :hidden-objects ((basis-surface :type 'rectangular-surface :length (twice (the radius)) :width (twice (the radius))) (island :type 'arc-curve :pass-down (radius)))) ;; ;; FLAG -- add Lift regression test in gendl/regression/source/ ;;
1,675
Common Lisp
.lisp
44
34.909091
72
0.744025
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b42a2ef04bde44583426d76a3ff66ddf10628952e15bf1d342389ca1eddc67df
35,808
[ -1 ]
35,809
csets.lisp
lisp-mirror_gendl/surf/source/csets.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object face-set (base-object) :input-slots (brep spec) :computed-slots ((found-faces (ecase (first (the spec)) (cset-nearest-to-point )))) :objects ((faces :type 'face :sequence (:size (length (the found-faces))) :%native-face% (the-object (nth (the-child index) (the found-faces)) %native-face%) :%native-brep% (the brep %native-brep%) :brep (the brep))))
1,384
Common Lisp
.lisp
33
35.969697
94
0.678354
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f8735bad1b4769f428d4e0c1c2247f3b401669a6b163f81e4ce5559027b8b7ac
35,809
[ -1 ]
35,810
sequenced-curves.lisp
lisp-mirror_gendl/surf/source/sequenced-curves.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object sequenced-curves (base-object) :input-slots (curve-list) :objects ((curves :type 'curve :sequence (:size (length (the curve-list))) :built-from (nth (the-child index) (the curve-list)))))
1,143
Common Lisp
.lisp
26
39.692308
76
0.708597
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b71bcbdb0254aee62aec208cd6e4a1abb531fb9acf41446b9ed653974c1a41f8
35,810
[ -1 ]
35,811
trimmed-surface.lisp
lisp-mirror_gendl/surf/source/trimmed-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object trimmed-surface (face) :input-slots ( ("GDL NURBS Surface. The underlying surface to be trimmed." basis-surface (the %extracted-basis%)) ("Single GDL NURBS Curve or list of same. These curves make up the outer trimming loop. Normally should be in counter-clockwise orientation; if not, please specify <tt>reverse-island?</tt> as non-NIL." island (list-elements (the basis-surface brep edges))) ("List of GDL NURBS Curves or list of lists of GDL NURBS Curves. These curves make up zero or more holes within the outer trimming loop. Normally should be in clockwise orientation; if not, please specify <tt>reverse-holes?</tt> as non-NIL." holes nil) (%native-brep% (let ((island-3d (when (the island) (mapcar #'(lambda (curve) (make-b-spline-curve* *geometry-kernel* (the-object curve native-curve) :schedule-finalization? nil)) (if (listp (the island)) (the island) (list (the island)))))) (holes-3d (mapcar #'(lambda (hole) (mapcar #'(lambda (curve) (make-b-spline-curve* *geometry-kernel* (the-object curve native-curve) :schedule-finalization? nil)) (if (listp hole) hole (list hole)))) (the holes))) (converted-basis (make-b-spline-surface* *geometry-kernel* (the native-surface) :schedule-finalization? nil) ;;(the basis-surface native-surface-iw) ) (brep (make-brep *geometry-kernel* :tolerance (the brep-tolerance)))) (let ((island-uv (when (the uv-inputs) (mapcar #'(lambda (curve) (make-b-spline-curve*-2d *geometry-kernel* curve)) island-3d))) (holes-uv (when (the uv-inputs) (mapcar #'(lambda (hole) (mapcar #'(lambda (curve) (make-b-spline-curve*-2d *geometry-kernel* curve)) hole)) ;;hack holes-3d)))) (make-trimmed-face *geometry-kernel* brep (when (not (the uv-inputs)) (cons island-3d holes-3d)) (cons island-uv holes-uv) (cons (if (the reverse-island?) 2 1) (make-list (length (the holes)) :initial-element (if (the reverse-holes?) 1 2))) nil converted-basis 1) (unless (the brep-tolerance) (brep-reset-tolerance *geometry-kernel* brep)) brep))) ("Boolean. NIL if feeding in 3D curves, non-NIL if feeding in UV curves." uv-inputs nil) ("Boolean. Specify this as non-NIL if the island is given in clockwise orientation. Default is NIL." reverse-island? nil) ("Boolean. Specify this as non-NIL if the holes are given in counter-clockwise orientation. Default is NIL." reverse-holes? nil)) :computed-slots (("Single GDL 3D NURBS Curve or list of GDL 3D NURBS Curves. These make up the outer trimming loop of the resultant trimmed surface. If you specified <tt>island</tt> as an input-slot, normally these should be the same or very similar. If the trimmed surface was read in from an outside system through a translator such as IGES, the <tt>result-island</tt> should return a non-NIL value while the <tt>island</tt> will return NIL." result-island (let ((island (list-elements (the %extracted-island%)))) (if (consp (rest island)) island (first island)))) ("List of GDL 3D NURBS Curves or list of lists of GDL 3D NURBS Curves. These make up the inner holes of the resultant trimmed surface. If you specified <tt>holes</tt> as an input-slot, normally these should be the same or very similar. If the trimmed surface was read in from an outside system through a translator such as IGES, the <tt>result-holes</tt> might return a non-NIL value while the <tt>island</tt> will always return NIL." result-holes (let ((holes (list-elements (the %extracted-holes%) (the-element curve-segments)))) (if (consp (rest holes)) holes (first holes)))) (%native-face% (first (get-faces-from-brep *geometry-kernel* (the %native-brep%)))) ;;(%curves-to-draw% (the face %curves-to-draw%)) (native-surface-iw (when (the basis-surface) (the basis-surface native-surface-iw))) (%curves-to-draw% (the brep %curves-to-draw%)) (outline-objects nil ) ) :hidden-objects (("GDL Brep Object. The Brep containing the face corresponding to this trimmed surface." brep :type 'brep :pass-down (%native-brep%)) ) :documentation (:description "Creates a surface which is trimmed by outer trimming loop curves (the ``island''), and one or more hole curves within the outer trimming loop. The curves can be input either as u-v curves or 3D curves. If 3D curves are given, they must lie on the surface. If not, please use dropped-curve or projected-curve to ensure that the curves lie on the surface. <p> Note that this object mixes in face, which mixes in surface. So this object should answer all the messages of both face and surface. However, the local surface messages will operate on the basis, not on the trimmed representation. The messages for face will operate on the trimmed representation. <p> NOTE: the interface for this object is still under development so please stay apprised of any changes." :examples "<pre> (in-package :surf) (define-object test-trimmed-surface-3 (trimmed-surface) :computed-slots ((reverse-holes? t) (island (the island-container ordered-curves)) (holes (list (the hole ordered-curves))) (display-controls (list :color :periwinkle :line-thickness 2))) :hidden-objects ((basis-surface :type 'test-planar-surface :display-controls (list :color :grey-light-very)) (island-container :type 'global-filleted-polyline-curves :default-radius .05 :vertex-list (list (make-point 0 0 0) (make-point 0.3 0.6 0) (make-point 0 1 0) (make-point 1 1 0) (make-point 1 0 0) (make-point 0 0 0))) (island-2 :type 'b-spline-curve :control-points (list (make-point 0 0 0) (make-point 0 1 0) (make-point 1 1 0) (make-point 1 0 0) (make-point 0 0 0))) (hole :type 'global-filleted-polyline-curves :default-radius .05 :vertex-list (list (make-point 0.5 0.5 0) (make-point 0.75 0.5 0) (make-point 0.75 0.75 0) (make-point 0.5 0.75 0) (make-point 0.5 0.5 0))))) (generate-sample-drawing :objects (make-object 'test-trimmed-surface-3) :projection-direction :trimetric) </pre>"))
8,529
Common Lisp
.lisp
137
47.423358
140
0.605406
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b3558ea8ead949e842addcdde359684c7d5ff207b7fd7532006883ee95ce90ce
35,811
[ -1 ]
35,812
native-reader.lisp
lisp-mirror_gendl/surf/source/native-reader.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object native-reader (base-object) :documentation (:description "This object will reflect the contents of an iwp file containing curves, surfaces, breps, and brep trees as sequences of GDL objects. ") :input-slots (("String or pathname. The location of the IWP file to be read." file-name (when (the smlib-string) (let ((temp-file (glisp:temporary-file))) (with-open-file (out temp-file :direction :output :if-exists :supersede :if-does-not-exist :create) (write-string (the smlib-string) out)) temp-file))) ("String. Contains output from a call to (with-format (native ...) (write-the cad-output)) for an SMLib object (e.g. curve, surface, brep). Defaults to nil. If you specify this as well as a file-name, the file-name will take precedence." smlib-string nil) (sew-and-shrink-breps? nil)) :computed-slots ((data (read-native-file *geometry-kernel* (format nil "~a" (translate-logical-pathname (the file-name))) :sew-and-shrink-breps? (the sew-and-shrink-breps?))) (breps-list (list-elements (the breps))) (surfaces-list (list-elements (the surfaces))) ) :objects ( ("Sequence of GDL curve objects. The curves found in the IWP file." curves :type 'curve :sequence (:size (length (getf (the data) :curves))) :native-curve-iw (nth (the-child index) (getf (the data) :curves)) ) ("Sequence of GDL surface objects. The untrimmed ``standalone'' surfaces found in the IWP file." surfaces :type 'surface :sequence (:size (length (getf (the data) :surfaces))) :native-surface-iw (nth (the-child index) (getf (the data) :surfaces))) ("Sequence of GDL brep objects. The breps found in the IGES file." breps :type 'brep :from-iges? t :sequence (:size (length (getf (the data) :breps))) :%native-brep% (nth (the-child index) (getf (the data) :breps)))))
3,142
Common Lisp
.lisp
64
39.75
107
0.631544
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
be85106d35ec150e4155932cdebdb0b869ed6bfa5ea35d231088e5a2c130362a
35,812
[ -1 ]
35,813
transformed-surface.lisp
lisp-mirror_gendl/surf/source/transformed-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object transformed-surface (transformed-bspline-mixin b-spline-surface) :input-slots (surface-in (from-location (the surface-in center)) (from-orientation (the surface-in orientation))) :computed-slots ( (orientation (the to-orientation)) (b-spline-list (multiple-value-bind (control-points weights u-knots v-knots u-degree v-degree) (the surface-in b-spline-data) (list :control-points control-points :weights weights :u-knots u-knots :v-knots v-knots :u-degree u-degree :v-degree v-degree))) (u-knot-vector (getf (the b-spline-list) :u-knots)) (v-knot-vector (getf (the b-spline-list) :v-knots)) (weights (getf (the b-spline-list) :weights)) (u-degree (getf (the b-spline-list) :u-degree)) (v-degree (getf (the b-spline-list) :v-degree)) (transformed-control-points (if (the surface-in rational?) (mapcar #'(lambda(point-row weight-row) (mapcar #'(lambda(point weight) (scalar*vector weight point)) point-row weight-row)) (the %transformed-control-points) (the weights)) (the %transformed-control-points))) (unweighted-points (if (the surface-in rational?) (mapcar #'(lambda(point-row weight-row) (mapcar #'(lambda(point weight) (scalar*vector (/ weight) point)) point-row weight-row)) (getf (the b-spline-list) :control-points) (the weights)) (getf (the b-spline-list) :control-points))) (%transformed-control-points (mapcar #'(lambda(point-list) (mapcar #'(lambda(point) (let ((transformed (the to-coord-space (local-to-global (the from-coord-space (global-to-local point)))))) (if (the scaling-needed?) (let ((local (the to-coord-space (global-to-local transformed)))) (the to-coord-space (local-to-global (make-point (* (get-x local) (the scale-x)) (* (get-y local) (the scale-y)) (* (get-z local) (the scale-z)))))) transformed))) point-list)) (the unweighted-points)))))
4,001
Common Lisp
.lisp
71
36.225352
105
0.497165
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2a6023b7dd035a1022fcc61a25ea3240d5dc5ee2abe00d70412fdb0f49852fb7
35,813
[ -1 ]
35,814
linear-curve.lisp
lisp-mirror_gendl/surf/source/linear-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (eval-when (:compile-toplevel :load-toplevel :execute) (define-object linear-curve () :input-slots (start end))) (define-object %linear-curve% (line curve) :computed-slots ((native-curve (make-linear-curve *geometry-kernel* (the start) (the end)))) :hidden-objects ((reverse :type 'linear-curve :start (the end) :end (the start)))) (define-object linear-curve (%linear-curve%) :documentation (:description "A GDL NURBS Curve representing a straight line segment. The inputs are the same as for l-line, namely <tt>start</tt> and <tt>end</tt> (3d points)." :examples "<pre> (in-package :surf) (define-object test-linear-curve (linear-curve) :computed-slots ((start (make-point 0 0 0)) (end (make-point 10 10 0)))) (generate-sample-drawing :objects (make-object 'test-linear-curve)) </pre>") :input-slots (line-constraints (start (if (the trim-start) (proj-point-on-line (the trim-start) (the constraint-object start) (the constraint-object direction-vector)) (the constraint-object start))) (end (if (the trim-end) (proj-point-on-line (the trim-end) (the constraint-object start) (the constraint-object direction-vector)) (the constraint-object end)))) :computed-slots ((trim-start (getf (the line-constraints) :trim-start)) (trim-end (getf (the line-constraints) :trim-end)) (constraints (let ((lst (the line-constraints))) (dolist (key (list :trim-start :trim-end) lst) (setq lst (remove-plist-key lst key))))) (keys (plist-keys (the constraints))) (exprs (plist-values (the constraints))) (constraint-type (cond ((every #'(lambda (key) (eql :through-point key)) (the keys)) :2-points) ((and (getf (the constraints) :through-point) (getf (the constraints) :at-angle)) :point-angle) ((and (getf (the constraints) :tangent-to) (getf (the constraints) :at-angle)) :tangent-angle) ((= (count :tangent-to (the keys)) 2) :tangent-tangent) ((and (getf (the constraints) :through-point) (getf (the constraints) :tangent-to)) :through-point-tangent-to) (t (error "Constrained-Line -- constraint configuration is not yet supported"))))) :hidden-objects ((constraint-object :type (case (the constraint-type) (:2-points 'line-constraints-2-points) (:point-angle 'line-constraints-point-angle) (:tangent-angle 'line-constraints-tangent-angle) (:tangent-tangent 'line-constraints-tangent-tangent) (:through-point-tangent-to 'line-contraints-through-point-tangent-to)) :constraints (the constraints))) :functions ((tangent-point (constraint-index) (when (member (the constraint-type) (list :tangent-angle :tangent-tangent)) (case constraint-index (0 (the constraint-object start)) (1 (the constraint-object end))))))) (define-object test-linear-curve (linear-curve) :computed-slots ((start (make-point 0 0 0)) (end (make-point 10 10 0))) :hidden-objects ((view :type 'base-view :pseudo-inputs (page-length page-width) :projection-vector (getf *standard-views* :trimetric) :page-width (* 5 72) :page-length (* 5 72) :objects (list self))))
4,844
Common Lisp
.lisp
98
37.561224
115
0.598831
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f1d61ce678fe113ee67169d0608622bb4325f68d24f78650b553e214cdd0a71f
35,814
[ -1 ]
35,815
brep-reader.lisp
lisp-mirror_gendl/surf/source/brep-reader.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object brep-reader (brep) :input-slots (file-name) :computed-slots ((%native-brep% (read-brep-from-file *geometry-kernel* (the file-name) :finalize-on self))))
1,071
Common Lisp
.lisp
26
38.346154
95
0.7343
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
42d9d719e6004185d22eda6e30f974f064bbd5a1fc35fc52fcb75947af697c3a
35,815
[ -1 ]
35,816
cone-solid.lisp
lisp-mirror_gendl/surf/source/cone-solid.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object cylinder-solid (brep cylinder) :documentation (:description "A right cylinder represented as a brep solid. Contains the union of messages (e.g. input-slots, computed-slots, etc) from brep and cylinder" :examples "<pre> (in-package :surf) (define-object test-cone-solid (cone-solid) :computed-slots ((display-controls (list :isos (list :n-u 8 :n-v 8) :color :green)) (length 100) (radius-1 10) (radius-2 20))) (generate-sample-drawing :objects (the-object (make-object 'test-cone-solid)) :projection-direction (getf *standard-views* :trimetric)) </pre>") :input-slots () :computed-slots ((%native-brep% (if (typep (the inner-cylinder) 'null-part) (the outer-cylinder %native-brep%) (the subtract %native-brep%)))) :hidden-objects ((outer-cylinder :type (if (and (the :radius-1) (the :radius-2)) 'simple-cone-solid 'simple-cylinder-solid) :pass-down (radius radius-1 radius-2 arc brep-tolerance)) (inner-cylinder :type (cond ((and (the :inner-radius-1) (the :inner-radius-2)) (if (not (and (< (the inner-radius-1) (the radius-1)) (< (the inner-radius-2) (the radius-2)))) (error "inner radius not less than radius for ~a.~%" (cons 'the (reverse (the root-path)))) 'simple-cone-solid)) ((the inner-radius) (if (not (< (the inner-radius) (the radius))) (error "inner radius not less than radius for ~a.~%" (cons 'the (reverse (the root-path)))) 'simple-cylinder-solid)) (t 'null-part)) :radius (the :inner-radius) :radius-1 (the :inner-radius-1) :radius-2 (the :inner-radius-2) :pass-down (arc brep-tolerance)) (subtract :type (if (typep (the inner-cylinder) 'null-part) 'null-part 'subtracted-solid) :brep (the outer-cylinder) :other-brep (the inner-cylinder)))) (define-object simple-cylinder-solid (brep cylinder) :computed-slots ((%native-brep% (let ((brep (make-brep *geometry-kernel* :tolerance (the brep-tolerance)))) (let ((x-vector (the (face-normal-vector :right))) (y-vector (the (face-normal-vector :bottom))) (corner (the (face-center :front)))) (let ((origin-x (get-x corner)) (origin-y (get-y corner)) (origin-z (get-z corner))) (add-cone-primitive *geometry-kernel* brep (the length) (the radius-1) (the radius-2) 0 (the arc) origin-x origin-y origin-z (get-x x-vector) (get-y x-vector) (get-z x-vector) (get-x y-vector) (get-y y-vector) (get-z y-vector)))) (unless (the brep-tolerance) (brep-reset-tolerance *geometry-kernel* brep)) brep)))) (define-object cone-solid (cylinder-solid cone) :documentation (:description "A right cone represented as a brep solid. Contains the union of messages (e.g. input-slots, computed-slots, etc) from brep and cone." :examples "<pre> (in-package :surf) (define-object test-cone-solid-hollow () :objects ((cone-solid :type 'cone-solid :display-controls (list :isos (list :n-u 8 :n-v 8) :color :green) :length 100 :radius-1 10 :radius-2 20 :inner-radius-1 8 :inner-radius-2 16))) (generate-sample-drawing :object-roots (make-object 'test-cone-solid-hollow) :projection-direction (getf *standard-views* :trimetric)) </pre>" )) (define-object simple-cone-solid (simple-cylinder-solid cone)) ;;(define-object test-cone-solid (cone-solid) ;; :computed-slots ;; ((display-controls (list :color :green)) ;; (length 100) (radius-1 10) (radius-2 20))) (define-object test-cone-solid-hollow () :objects ((cone-solid :type 'cone-solid :display-controls (list :color :green) :length 100 :radius-1 10 :radius-2 20 :inner-radius-1 8 :inner-radius-2 16)))
5,569
Common Lisp
.lisp
107
38.859813
149
0.579037
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e1c7b79b2282c9cc0749ec64107cea738d019990542969bb0b04f4da3927d097
35,816
[ -1 ]
35,817
views.lisp
lisp-mirror_gendl/surf/source/views.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-lens (nurbs vanilla-mixin)() :output-functions ((cad-output-tree () (with-format-slots (assembly?) (if (not assembly?) (call-next-method) (write-the cad-output-assembly-tree)))) (cad-output-assembly-tree (&optional (assembly-instance (let ((assembly (make-tx-assembly-instance *geometry-kernel* :name (the strings-for-display)))) (set-format-slot %assembly% assembly) assembly))) (dolist (child (the children)) (if (the-object child children) ;; ;; Add subassemblies ;; ;; ;; FLAG -- add object also in case there is actual geometry here. ;; (let ((child-assembly-instance (make-tx-assembly-instance *geometry-kernel* :name (the-object child strings-for-display)))) (write-the-object child (cad-output-assembly-tree child-assembly-instance)) (tx-assembly-add-subassembly *geometry-kernel* assembly-instance child-assembly-instance)) ;; ;; Add objects ;; (write-the-object child (cad-output-assembly assembly-instance))))) (cad-output-assembly (assembly-instance) (declare (ignore assembly-instance)) (format t "No cad-output-assembly action is defined for ~s with root-path ~s~%" self (the root-path))) (cad-output () (with-format-slots (assembly?) (unless assembly? (push self (format-slot objects))))) (nurbs-reps () (warn "No NURBS representation for ~s, apparently of type ~s" self (the type))))) (define-lens (nurbs surface) () :output-functions ((cad-output-assembly (assembly-instance) (let ((color (lookup-color (getf (the display-controls) :color)))) (tx-assembly-add-brep *geometry-kernel* assembly-instance (the brep %native-brep%) :name (the strings-for-display) :red (get-x color) :green (get-y color) :blue (get-z color)))))) (define-lens (nurbs brep) () :output-functions ((cad-output-assembly (assembly-instance) (let ((color (lookup-color (getf (the display-controls) :color)))) (tx-assembly-add-brep *geometry-kernel* assembly-instance (the %native-brep%) :name (the strings-for-display) :red (get-x color) :green (get-y color) :blue (get-z color)))))) (define-lens (nurbs curve) () :output-functions ((cad-output-assembly (assembly-instance) (let ((color (lookup-color (getf (the display-controls) :color)))) (tx-assembly-add-curve *geometry-kernel* assembly-instance (the native-curve-iw) :name (the strings-for-display) :red (get-x color) :green (get-y color) :blue (get-z color)))))) (define-lens (nurbs point) () :output-functions ((cad-output-assembly (assembly-instance) (let ((color (lookup-color (getf (the display-controls) :color)))) (tx-assembly-add-point *geometry-kernel* assembly-instance (the center) :name (the strings-for-display) :red (get-x color) :green (get-y color) :blue (get-z color)))))) (define-lens (nurbs line)() :output-functions ((nurbs-reps () (make-object 'linear-curve :start (the start) :end (the end))))) (define-lens (nurbs arc) () :output-functions ((nurbs-reps () (make-object 'arc-curve :radius (the radius) :start-angle (the start-angle-normalized) :end-angle (the end-angle-normalized) :center (the center) :orientation (the orientation))))) (define-lens (nurbs sphere) () :output-functions ((nurbs-reps () ;; ;; FLAG -- add support for spherical patches. ;; (make-object 'spherical-surface :center (the center) :radius (the radius))))) (define-lens (nurbs global-filleted-polyline)() :output-functions ((nurbs-reps () (append (mapcar #'(lambda(straight) (destructuring-bind (start end) straight (make-object 'linear-curve :start start :end end))) (the straights)) (mapcar #'(lambda(arc) (make-object 'arc-curve :radius (the-object arc radius) :start-angle (the-object arc start-angle-normalized) :end-angle (the-object arc end-angle-normalized) :center (the-object arc center) :orientation (the-object arc orientation))) (list-elements (the fillets))))))) (define-lens (nurbs global-polyline)() :output-functions ((nurbs-reps () (mapcar #'(lambda(line) (destructuring-bind (start end) line (make-object 'linear-curve :start start :end end))) (the lines))))) (define-lens (nurbs cylinder)() :output-functions ((nurbs-reps () (append (mapcar #'(lambda(arc) (make-object 'arc-curve :radius (the-object arc radius) :start-angle (the-object arc start-angle-normalized) :end-angle (the-object arc end-angle-normalized) :center (the-object arc center) :orientation (the-object arc orientation))) (list-elements (the end-arcs))) (mapcar #'(lambda(line) (destructuring-bind (start end) line (make-object 'linear-curve :start start :end end))) (the %lines-to-draw%)) (unless (typep (the inner-cylinder) 'null-part) (write-the inner-cylinder nurbs-reps)))))) (define-lens (nurbs global-polygon-projection)() :output-functions ((nurbs-reps () (append (write-the polygon-original nurbs-reps) (write-the polygon-1 nurbs-reps) (when (typep (the :polygon-2) (the :polygon-type)) (write-the polygon-2 nurbs-reps)) (mapcar #'(lambda(line) (make-object 'linear-curve :start (first line) :end (second line))) (the projection-lines))))))
7,331
Common Lisp
.lisp
173
32.184971
113
0.595863
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7b4d84b40db1422c920f59bc79bdfba58f1b6b04a6484a600db148fb7f72b2c6
35,817
[ -1 ]
35,818
surface-knot-reduction.lisp
lisp-mirror_gendl/surf/source/surface-knot-reduction.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object surface-knot-reduction (surface) :documentation (:description "This routine removes all removable knots from a GDL surface." :examples "<pre> (in-package :gdl-user) (define-object surface-knot-reduction-test (base-object) :input-slots ((control-points (list (make-point 0 0 0) (make-point 2 3.0 0.0) (make-point 4 2.0 0.0) (make-point 5 0.0 0.0) (make-point 4 -2.0 0.0) (make-point 2 -3.0 0.0) (make-point 0 0 0)))) :objects ((curve-1 :type 'b-spline-curve :display-controls (list :line-thickness 2 :color :green-spring-medium) :control-points (the control-points)) (curve-2 :type 'boxed-curve :display-controls (list :line-thickness 2 :color :blue) :curve-in (the curve-1) :center (make-point 0 0 8)) (curve-3 :type 'transformed-curve :display-controls (list :line-thickness 2 :color :green) :curve-in (the curve-1) :to-location (translate (the center) :up 3) :center (the center) :scale-x 1.3 :scale-y 1.3) (curve-4 :type 'transformed-curve :display-controls (list :line-thickness 2 :color :red) :curve-in (the curve-1) :to-location (translate (the center) :up 7) :center (the center) :scale-x 2.2 :scale-y 2.2) (lofted-surface-test-simple :type 'lofted-surface :display-controls (list :color :red-violet :isos (list :n-v 19 :n-u 19)) :tolerance 0.01 :curves (list (the curve-1) (the curve-3) (the curve-4) (the curve-2))) (S-knot-reduction :type 'surface-knot-reduction :surface (the lofted-surface-test-simple)))) </pre> ") :input-slots (("Gdl surface object." surface) ("Number." tolerance 0.025) ("Keyword symbol, one of :u, :v or :uv. Default is :uv." direction :uv)) :computed-slots ((native-surface (reduce-surface-knot *geometry-kernel* (the surface) :tolerance (the tolerance) :direction (the direction)))))
3,838
Common Lisp
.lisp
78
32.25641
100
0.50676
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
93b3e973a6dc2af83b077dc7ae0dd928830e7f968cc691717daee3bdc5b09fff
35,818
[ -1 ]
35,819
transformed-curve.lisp
lisp-mirror_gendl/surf/source/transformed-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object boxed-curve (outline-specialization-mixin b-spline-curve) :documentation (:description "This object behaves as a hybrid of a curve and a normal box. You pass in a curve-in, and it essentially traps the curve in a box, which will respond to normal GDL :center and :orientation. You can also pass a scale, or scale-x, or scale-y, or scale-z as with a transformed-curve." :examples "<pre> (define-object boxed-curves-test (base-object) :computed-slots ((b-spline (the b-splines (curves 2)))) :objects ((b-splines :type 'test-b-spline-curves) (boxed :type 'boxed-curve :curve-in (the b-splines (curves 2))) (translated :type 'boxed-curve :curve-in (the b-spline) :center (translate (the center) :left 15)) (twisted :type 'boxed-curve :curve-in (the boxed) :orientation (alignment :left (the (face-normal-vector :top)) :rear (rotate-vector-d (the (face-normal-vector :rear)) 30 (the (face-normal-vector :top))))) (rotated :type 'boxed-curve :curve-in (the b-spline) :display-controls (list :color :purple) :orientation (alignment :left (rotate-vector-d (the (face-normal-vector :left)) 50 (the (face-normal-vector :rear))))) (rotated-about :type 'boxed-curve :curve-in (the b-spline) :display-controls (list :color :purple) :orientation-center (translate (the center) :right 2.5) ;;:center (translate (the center) :up 5) :orientation (alignment :left (rotate-vector-d (the (face-normal-vector :left)) 45 (the (face-normal-vector :rear))))) (moved-up :type 'boxed-curve :curve-in (the rotated-about) :center (translate (the rotated-about center) :up 7 :left 5)) (straightened :type 'boxed-curve :curve-in (the moved-up) :orientation (alignment :left (rotate-vector-d (the-child curve-in (face-normal-vector :left)) 45 (the-child curve-in (face-normal-vector :rear))) :rear (the-child curve-in (face-normal-vector :rear)))) (rotated-straightened :type 'boxed-curve :curve-in (the straightened) :orientation (the moved-up orientation) :orientation-center (translate (the-child curve-in center) :up 2.5)) (rotated-straightened-moved :type 'boxed-curve :curve-in (the rotated-straightened) :center (translate (the-child curve-in center) :right 5)) (center-sphere :type 'sphere :radius 0.3 :center (the moved-up-and-straightened orientation-center)) (moved-up-and-straightened :type 'boxed-curve :curve-in (the straightened) :center (translate (the-child orientation-center) :right 7) :orientation (alignment :left (the-child curve-in (face-normal-vector :rear)) :front (rotate-vector-d (the-child curve-in (face-normal-vector :left)) 45 (the-child curve-in (face-normal-vector :rear)))) :orientation-center (translate (the straightened center) :up 2.5)) (moved-up-and-straightened-1 :type 'boxed-curve :curve-in (the straightened) :center (translate (the-child curve-in center) :right 14) :orientation (the rotated-straightened orientation) :orientation-center (translate (the straightened center) :up 2.5)) (moved-up-and-straightened-2 :type 'boxed-curve :curve-in (the straightened) :center (translate (the-child curve-in center) :right 21) :orientation (the rotated-straightened orientation) :orientation-center (translate (the straightened center) :up 2.5)) (transformed :type 'boxed-curve :curve-in (the b-spline) :center (translate (the center) :left 50) :orientation (alignment :rear (rotate-vector-d (the (face-normal-vector :rear)) 30 (the (face-normal-vector :right))))))) </pre> ") :input-slots ("GDL Curve object. This can be any type of curve, e.g. b-spline-curve, fitted-curve, or an edge from a solid brep. Note that the reference-box of this curve (i.e. its center and orientation) will have an effect on the resulting boxed-curve. If you want to consider the incoming curve-in as being in global space, then make sure its center is (0 0 0) and its orientation is nil or equivalent to geom-base::+identity-3x3+" curve-in ("Boolean. This determines whether the reference box is displayed along with the curve. Default is t (will be changed to nil)." show-box? nil) ("Boolean. This determines whether the tight box is displayed along with the curve. Default is nil." show-tight-box? nil) ("Boolean. This determines whether the control polygon is displayed along with the curve. Default is nil." show-control-polygon? nil) ("3x3 Transformation Matrix. This will be the new orientation for the box and the contained curve. Default is (the curve-in orientation) -- i.e. identical orientation with the provided curve-in." orientation (the curve-in% orientation)) ("3D Point in global space. If you provide this, the curve's reference box will be moved to have its center at this point, before any orientation is applied. This will become the new center of the resulting boxed-curve, unless you explicitly pass in a different center. Default is nil." orientation-center nil) ("3D Point in global space. You can pass in a new center for the curve's reference box, which will move the whole box including the curve. This defaults to the orientation-center (if given), otherwise to the (the curve-in center)." center (or (the orientation-center) (the curve-in% center))) ("GDL object which mixes in base-object. The current boxed-curve will be positioned and oriented with respect to the center and orientation of this object. The default is (the curve-in)." from-object (the curve-in%)) ("3x3 Transformation Matrix. The orientation with respect to which this object should be oriented. Normally this should not be specified by user code, unless you know what you are doing [e.g. to override the orientation of a curve-in which is meaningless and force it to be interpreted as a curve in the parent's coordinate system, you could specify this as (the orientation) when passing it in from the parent]. Default is (the curve-in orientation)." from-orientation (the from-object orientation) ) ("3D Point in global space. The center with respect to which this object should be positioned. Normally this should not be specified by user code, unless you know what you are doing [e.g. to override the center of a curve-in which is meaningless and force it to be interpreted as a curve in global space, you could specify this as (the center) when passing it in from the parent]. Default is (the curve-in center)." from-center (the from-object center)) ("Number. The overall scale factor for X, Y, and Z, if no individual scales are specified. Defaults to 1." scale 1) ("Number. The scale factor for X. Defaults to 1." scale-x (the scale)) ("Number. The scale factor for Y. Defaults to 1." scale-y (the scale)) ("Number. The scale factor for Z. Defaults to 1." scale-z (the scale)) ("Number. Tolerance to determine whether the boxed-curve has moved with respect to the original. Default is *zero-epsilon*" translation-threshold *zero-epsilon*) ) :computed-slots ((curve-in% (if (null (the curve-in)) (error "You must pass a non-nil curve-in into boxed-curve at ~s~%" (cons 'the (reverse (the root-path)))) (the curve-in))) (translated? (the orientation-center)) (moved? (not (coincident-point? (the from-center) (the center) :tolerance (the translation-threshold)))) (oriented? (not (equalp (the orientation) (the from-orientation)))) (width (the curve-in% box-width)) (length (the curve-in% box-length)) (height (the curve-in% box-height)) (degree (the curve-in% degree)) (knot-vector (the curve-in% knot-vector)) (weights (the curve-in% weights)) (translation (when (the translated?) (subtract-vectors (the from-center) (the orientation-center)))) #+nil (unweighted (if (the curve-in% rational?) (mapcar #'(lambda(point weight) (scalar*vector (/ weight) point)) (the curve-in% control-points) (the curve-in% weights)) (the curve-in% control-points))) (unweighted (the curve-in% control-points)) (scaled (if (every #'(lambda(value) (= value 1)) (list (the scale-x) (the scale-y) (the scale-z))) (the unweighted) (mapcar #'(lambda(point) (let ((local (the from-orientation-object (global-to-local point)))) (the from-orientation-object (local-to-global (make-point (* (get-x local) (the scale-x)) (* (get-y local) (the scale-y)) (* (get-z local) (the scale-z))))))) (the unweighted)))) (translated (if (the translated?) (mapcar #'(lambda(point) (add-vectors point (the translation))) (the scaled)) (the scaled))) (oriented (if (the oriented?) (mapcar #'(lambda(point) (the to-orientation-object (local-to-global (the from-orientation-object (global-to-local point))))) (the translated)) (the translated))) (restored (if (the translated?) (mapcar #'(lambda(point) (add-vectors point (subtract-vectors (the orientation-center) (the from-center)))) (the oriented)) (the oriented))) (control-points (the %control-points)) #+nil (control-points (if (the curve-in% rational?) (mapcar #'(lambda(point weight) (scalar*vector weight point)) (the %control-points) (the weights)) (the %control-points))) (%control-points (if (the moved?) (mapcar #'(lambda(point) (add-vectors point (subtract-vectors (the center) (or (the orientation-center) (the from-center))))) (the restored)) (the restored))) (outline-objects (cons (the curve) (append (when (the show-box?) (list (the box))) (when (the show-tight-box?) (list (the tight-box))) (when (the show-control-polygon?) (list (the control-polygon))))))) :hidden-objects ((curve :type 'curve :native-curve (the native-curve) :display-controls (the display-controls)) (box :type 'box) (control-polygon :type 'global-polyline :display-controls (list :color :green) :vertex-list (the b-spline-data)) (from-orientation-object :type 'base-object :center (the from-center) :orientation (the from-orientation)) (to-orientation-object :type 'base-object :center (the from-center)))) (define-object boxed-surfaces-test (base-object) ;;bounding-box-from-points gives errors :objects ((b-spline :type 'test-b-spline-surface) (boxed :type 'boxed-surface :surface-in (the b-spline)) (translated :type 'boxed-surface :surface-in (the b-spline) :center (translate (the center) :left 15)) (twisted :type 'boxed-surface :surface-in (the boxed) :orientation (alignment :left (the (face-normal-vector :top)) :rear (rotate-vector-d (the (face-normal-vector :rear)) 30 (the (face-normal-vector :top))))) (rotated :type 'boxed-surface :surface-in (the b-spline) :display-controls (list :color :purple) :orientation (alignment :left (rotate-vector-d (the (face-normal-vector :left)) 50 (the (face-normal-vector :rear))))) (rotated-about :type 'boxed-surface :surface-in (the b-spline) :display-controls (list :color :purple) :orientation-center (translate (the center) :right 2.5) ;;:center (translate (the center) :up 5) :orientation (alignment :left (rotate-vector-d (the (face-normal-vector :left)) 45 (the (face-normal-vector :rear))))) (moved-up :type 'boxed-surface :surface-in (the rotated-about) :center (translate (the rotated-about center) :up 7 :left 5)) (straightened :type 'boxed-surface :surface-in (the moved-up) :orientation (alignment :left (rotate-vector-d (the-child surface-in (face-normal-vector :left)) 45 (the-child surface-in (face-normal-vector :rear))) :rear (the-child surface-in (face-normal-vector :rear)))) (rotated-straightened :type 'boxed-surface :surface-in (the straightened) :orientation (the moved-up orientation) :orientation-center (translate (the-child surface-in center) :up 2.5) ) (rotated-straightened-moved :type 'boxed-surface :surface-in (the rotated-straightened) :center (translate (the-child surface-in center) :right 5)) (center-sphere :type 'sphere :radius 0.3 :center (the moved-up-and-straightened orientation-center)) (moved-up-and-straightened :type 'boxed-surface :surface-in (the straightened) :center (translate (the-child orientation-center) :right 7) :orientation (alignment :left (the-child surface-in (face-normal-vector :rear)) :front (rotate-vector-d (the-child surface-in (face-normal-vector :left)) 45 (the-child surface-in (face-normal-vector :rear)))) :orientation-center (translate (the straightened center) :up 2.5) ) (moved-up-and-straightened-1 :type 'boxed-surface :surface-in (the straightened) :center (translate (the-child surface-in center) :right 14) :orientation (the rotated-straightened orientation) :orientation-center (translate (the straightened center) :up 2.5) ) (moved-up-and-straightened-2 :type 'boxed-surface :surface-in (the straightened) :center (translate (the-child surface-in center) :right 21) :orientation (the rotated-straightened orientation) :orientation-center (translate (the straightened center) :up 2.5) ) (transformed :type 'boxed-surface :surface-in (the b-spline) :center (translate (the center) :left 50) :orientation (alignment :rear (rotate-vector-d (the (face-normal-vector :rear)) 30 (the (face-normal-vector :right))))))) (define-object boxed-surface (b-spline-surface) :documentation (:description "This object behaves as a hybrid of a surface and a normal box. You pass in a surface-in, and it essentially traps the surface in a box, which will respond to normal GDL :center and :orientation. You can also pass a scale, or scale-x, or scale-y, or scale-z as with a transformed-surface." :examples "<pre> (define-object boxed-surfaces-test (base-object) ;;bounding-box-from-points gives errors :objects ((b-spline :type 'test-b-spline-surface) (boxed :type 'boxed-surface :surface-in (the b-spline)) (translated :type 'boxed-surface :surface-in (the b-spline) :center (translate (the center) :left 15)) (twisted :type 'boxed-surface :surface-in (the boxed) :orientation (alignment :left (the (face-normal-vector :top)) :rear (rotate-vector-d (the (face-normal-vector :rear)) 30 (the (face-normal-vector :top))))) (rotated :type 'boxed-surface :surface-in (the b-spline) :display-controls (list :color :purple) :orientation (alignment :left (rotate-vector-d (the (face-normal-vector :left)) 50 (the (face-normal-vector :rear))))) (rotated-about :type 'boxed-surface :surface-in (the b-spline) :display-controls (list :color :purple) :orientation-center (translate (the center) :right 2.5) ;;:center (translate (the center) :up 5) :orientation (alignment :left (rotate-vector-d (the (face-normal-vector :left)) 45 (the (face-normal-vector :rear))))) (moved-up :type 'boxed-surface :surface-in (the rotated-about) :center (translate (the rotated-about center) :up 7 :left 5)) (straightened :type 'boxed-surface :surface-in (the moved-up) :orientation (alignment :left (rotate-vector-d (the-child surface-in (face-normal-vector :left)) 45 (the-child surface-in (face-normal-vector :rear))) :rear (the-child surface-in (face-normal-vector :rear)))) (rotated-straightened :type 'boxed-surface :surface-in (the straightened) :orientation (the moved-up orientation) :orientation-center (translate (the-child surface-in center) :up 2.5)) (rotated-straightened-moved :type 'boxed-surface :surface-in (the rotated-straightened) :center (translate (the-child surface-in center) :right 5)) (center-sphere :type 'sphere :radius 0.3 :center (the moved-up-and-straightened orientation-center)) (moved-up-and-straightened :type 'boxed-surface :surface-in (the straightened) :center (translate (the-child orientation-center) :right 7) :orientation (alignment :left (the-child surface-in (face-normal-vector :rear)) :front (rotate-vector-d (the-child surface-in (face-normal-vector :left)) 45 (the-child surface-in (face-normal-vector :rear)))) :orientation-center (translate (the straightened center) :up 2.5)) (moved-up-and-straightened-1 :type 'boxed-surface :surface-in (the straightened) :center (translate (the-child surface-in center) :right 14) :orientation (the rotated-straightened orientation) :orientation-center (translate (the straightened center) :up 2.5)) (moved-up-and-straightened-2 :type 'boxed-surface :surface-in (the straightened) :center (translate (the-child surface-in center) :right 21) :orientation (the rotated-straightened orientation) :orientation-center (translate (the straightened center) :up 2.5)) (transformed :type 'boxed-surface :surface-in (the b-spline) :center (translate (the center) :left 50) :orientation (alignment :rear (rotate-vector-d (the (face-normal-vector :rear)) 30 (the (face-normal-vector :right))))))) </pre>") :input-slots ("GDL Surface object. This can be any type of surface, e.g. b-spline-surface, fitted-surface, or an edge from a solid brep. Note that the reference-box of this surface (i.e. its center and orientation) will have an effect on the resulting boxed-surface. If you want to consider the incoming surface-in as being in global space, then make sure its center is (0 0 0) and its orientation is nil or equivalent to geom-base::+identity-3x3+" surface-in ("Boolean. This determines whether the reference box is displayed along with the surface. Default is nil." show-box? nil) ("Boolean. This determines whether the tight box is displayed along with the surface. Default is nil." show-tight-box? nil) ("Boolean. This determines whether the control polygon is displayed along with the surface. Default is t (will be changed to nil)." show-control-polygon? nil) ("3x3 Transformation Matrix. This will be the new orientation for the box and the contained surface. Default is (the surface-in orientation) -- i.e. identical orientation with the provided surface-in." orientation (the surface-in% orientation)) ("3D Point in global space. If you provide this, the surface's reference box will be moved to have its center at this point, before any orientation is applied. This will become the new center of the resulting boxed-surface, unless you explicitly pass in a different center. Default is nil." orientation-center nil) ("3D Point in global space. You can pass in a new center for the surface's reference box, which will move the whole box including the surface. This defaults to the orientation-center (if given), otherwise to the (the surface-in center)." center (or (the orientation-center) (the surface-in% center))) ("GDL object which mixes in base-object. The current boxed-surface will be positioned and oriented with respect to the center and orientation of this object. The default is (the surface-in)." from-object (the surface-in%)) ("3x3 Transformation Matrix. The orientation with respect to which this object should be oriented. Normally this should not be specified by user code, unless you know what you are doing [e.g. to override the orientation of a surface-in which is meaningless and force it to be interpreted as a surface in the parent's coordinate system, you could specify this as (the orientation) when passing it in from the parent]. Default is (the surface-in orientation)." from-orientation (the from-object orientation)) ("3D Point in global space. The center with respect to which this object should be positioned. Normally this should not be specified by user code, unless you know what you are doing [e.g. to override the center of a surface-in which is meaningless and force it to be interpreted as a surface in global space, you could specify this as (the center) when passing it in from the parent]. Default is (the surface-in orientation)." from-center (the from-object center)) ("Number. The overall scale factor for X, Y, and Z, if no individual scales are specified. Defaults to 1." scale 1) ("Number. The scale factor for X. Defaults to 1." scale-x (the scale)) ("Number. The scale factor for Y. Defaults to 1." scale-y (the scale)) ("Number. The scale factor for Z. Defaults to 1." scale-z (the scale))) :computed-slots ( (surface-in% (or (the surface-in) (error "You must pass a non-nil surface-in into boxed-surface at ~s~%" (cons 'the (reverse (the root-path)))))) (translated? (the orientation-center)) (moved? (not (coincident-point? (the from-center) (the center)))) (oriented? (not (equalp (the orientation) (the from-orientation)))) (width (the surface-in% width)) (length (the surface-in% length)) (height (the surface-in% height)) (u-degree (the surface-in% u-degree)) (v-degree (the surface-in% v-degree)) (u-knot-vector (the surface-in% u-knot-vector)) (v-knot-vector (the surface-in% v-knot-vector)) (weights (the surface-in% weights)) (translation (when (the translated?) (subtract-vectors (the from-center) (the orientation-center)))) #+nil (unweighted (if (the surface-in% rational?) (mapcar #'(lambda(point-row weight-row) (mapcar #'(lambda(point weight) (scalar*vector (/ weight) point)) point-row weight-row)) (the surface-in% control-points) (the surface-in% weights)) (the surface-in% control-points))) (unweighted (the surface-in% control-points)) (scaled (if (every #'(lambda(value) (= value 1)) (list (the scale-x) (the scale-y) (the scale-z))) (the unweighted) (mapcar #'(lambda(row) (mapcar #'(lambda(point) (let ((local (the from-orientation-object (global-to-local point)))) (the from-orientation-object (local-to-global (make-point (* (get-x local) (the scale-x)) (* (get-y local) (the scale-y)) (* (get-z local) (the scale-z))))))) row)) (the unweighted)))) (translated (if (the translated?) (mapcar #'(lambda(row) (mapcar #'(lambda(point) (add-vectors point (the translation))) row)) (the scaled)) (the scaled))) (oriented (if (the oriented?) (mapcar #'(lambda(row) (mapcar #'(lambda(point) (the to-orientation-object (local-to-global (the from-orientation-object (global-to-local point))))) row)) (the translated)) (the translated))) (restored (if (the translated?) (mapcar #'(lambda(row) (mapcar #'(lambda(point) (add-vectors point (subtract-vectors (the orientation-center) (the from-center)))) row)) (the oriented)) (the oriented))) #+nil (control-points (if (the surface-in% rational?) (mapcar #'(lambda(point-row weight-row) (mapcar #'(lambda(point weight) (scalar*vector weight point)) point-row weight-row)) (the %control-points) (the weights)) (the %control-points))) (control-points (the %control-points)) (%control-points (if (the moved?) (mapcar #'(lambda(row) (mapcar #'(lambda(point) (add-vectors point (subtract-vectors (the center) (or (the orientation-center) (the from-center))))) row)) (the restored)) (the restored))) (outline-objects (cons (the surface) (append (when (the show-box?) (list (the box))) (when (the show-tight-box?) (list (the tight-box))) (when (the show-control-polygon?) (list (the control-polygon))))))) :hidden-objects ((surface :type 'surface :native-surface (the native-surface)) ;;(box :type 'box) (control-polygon :type 'global-polyline :display-controls (list :color :green) :vertex-list (the b-spline-data)) (from-orientation-object :type 'base-object :center (the from-center) :orientation (the from-orientation)) (to-orientation-object :type 'base-object :center (the from-center)))) (define-object transformed-bspline-mixin () :input-slots ((from-location (the center)) (to-location (the from-location)) (to-orientation (the from-orientation)) (center (the to-location)) (scale 1) (scale-x (the scale)) (scale-y (the scale)) (scale-z (the scale))) :computed-slots ((control-points (the transformed-control-points)) (weights (getf (the b-spline-list) :weights)) (scaling-needed? (some #'(lambda(value) (/= value 1)) (list (the scale-x) (the scale-y) (the scale-z))))) :hidden-objects ((from-coord-space :type 'base-object :orientation (or (the from-orientation) geom-base::+identity-3x3+) :center (the from-location)) (to-coord-space :type 'base-object :orientation (or (the to-orientation) geom-base::+identity-3x3+) :center (the to-location)))) (define-object transformed-curve (curve) :input-slots (curve-in (from-location (the curve-in center)) (to-location (the from-location)) (from-orientation (the curve-in orientation)) (to-orientation (the from-orientation)) (scale 1) (scale-x (the scale)) (scale-y (the scale)) (scale-z (the scale)) (center (the curve-in center))) :computed-slots ( (orientation (the to-orientation)) (composed? nil ;;(> (the decomposed curves number-of-elements) 1) ) (built-from (if (the composed?) (the composed-curve) (the transformed first)))) :hidden-objects ((decomposed :type 'decomposed-curves :curve-in (the curve-in)) (composed-curve :type (if (the composed?) 'composed-curve 'null-part) :curves (list-elements (the transformed))) (transformed :type 'transformed-curve* :sequence (:size 1) ;;(:size (the decomposed curves number-of-elements)) :curve-in (the curve-in) ;;(the decomposed (curves (the-child index))) :pass-down (curve-in from-location to-location from-orientation to-orientation scale scale-x scale-y scale-z)))) (define-object transformed-curve* (transformed-bspline-mixin b-spline-curve) :input-slots (curve-in (from-orientation (the curve-in orientation))) :computed-slots ( (b-spline-list (multiple-value-bind (control-points weights knots degree) (the curve-in b-spline-data) (list :control-points control-points :weights weights :knots knots :degree degree))) (knot-vector (getf (the b-spline-list) :knots)) (degree (getf (the b-spline-list) :degree)) (transformed-control-points (if (the curve-in rational?) (mapcar #'(lambda(point weight) (scalar*vector weight point)) (the %transformed-control-points) (the weights)) (the %transformed-control-points))) (unweighted-points (if (the curve-in rational?) (mapcar #'(lambda(point weight) (scalar*vector (/ weight) point)) (getf (the b-spline-list) :control-points) (the weights)) (getf (the b-spline-list) :control-points))) (%transformed-control-points (mapcar #'(lambda(point) (let ((transformed (the to-coord-space (local-to-global (the from-coord-space (global-to-local point)))))) (if (the scaling-needed?) (let ((local (the to-coord-space (global-to-local transformed)))) (the to-coord-space (local-to-global (make-point (* (get-x local) (the scale-x)) (* (get-y local) (the scale-y)) (* (get-z local) (the scale-z)))))) transformed))) (the unweighted-points)))))
38,933
Common Lisp
.lisp
665
38.753383
136
0.530681
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cd5558a642a58816e58f758939a74435ed8a897ec511635c931bfd872cd32628
35,819
[ -1 ]
35,820
region.lisp
lisp-mirror_gendl/surf/source/region.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object region (geometry-kernel-object-mixin base-object) :input-slots (%native-region% %native-brep% brep) :computed-slots ((%native-shells% (get-shells-from-region *geometry-kernel* (the %native-region%)))) :hidden-objects ((shells :type 'brep-shell :sequence (:size (length (the %native-shells%))) :%native-shell% (nth (the-child index) (the %native-shells%)))))
1,309
Common Lisp
.lisp
28
42.857143
103
0.718131
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
86ce397333f188fb2c3ba704941651fd4e643cdecb80016e663931903d70fa3c
35,820
[ -1 ]
35,821
cad-assembly.lisp
lisp-mirror_gendl/surf/source/cad-assembly.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object cad-assembly (base-object) :documentation (:description "Represents a hierarchical CAD assembly for import into GDL.") :input-slots ((file-name nil) ("GDL smlib:assembly-import object. Normally this should be left to its default value. Defaults to the assembly-import produced from the file-name. " imported-assembly (the assembly-import)) (display-controls (the imported-assembly display-controls)) (orientation (the imported-assembly orientation)) (center (the imported-assembly center)) (sub-assemblies-pruned (the imported-assembly effective-subassies)) (entities-pruned (remove-if #'(lambda(entity) (the-object entity prune?)) (list-elements (the imported-assembly hw-objects)))) (strings-for-display (the imported-assembly strings-for-display)) ) :objects ((sub-assemblies :type 'cad-assembly :sequence (:size (length (the sub-assemblies-pruned))) :imported-assembly (nth (the-child index) (the sub-assemblies-pruned))) (entities :type 'cad-entity :sequence (:size (length (the entities-pruned))) :imported-entity (nth (the-child index) (the entities-pruned)))) :hidden-objects ((assembly-import :type (if (the file-name) (read-from-string "smlib::assembly-import") 'null-object) :pass-down (file-name)))) (define-object cad-entity (base-object) :input-slots (imported-entity) :computed-slots ((display-controls (the imported-entity display-controls)) (strings-for-display (the imported-entity strings-for-display)) (imported-item (the imported-entity item)) (brep-transformed (the imported-entity brep-transformed)) (effective-coord-sys? (the imported-entity effective-coord-sys?))) :objects ((item :type (the imported-item type) :strings-for-display (the imported-item strings-for-display) :hidden? (the imported-item hidden?) :center (the imported-item center) :native-pointer (the imported-item native-pointer) :effective-coord-sys? (the imported-item effective-coord-sys?)) (brep :type (the brep-transformed type) :brep (the brep-transformed brep) :hidden? (the brep-transformed hidden?) :strings-for-display (the brep-transformed strings-for-display) :to-orientation (the brep-transformed to-orientation) :from-orientation (the brep-transformed from-orientation) :to-location (the brep-transformed to-location) :from-location (the brep-transformed from-location))))
3,334
Common Lisp
.lisp
68
45.294118
103
0.74644
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6db57f6d5f2a40af657416cdc0d6a16e5dbe30d2b1e4d3a660889cabd8b8c365
35,821
[ -1 ]
35,822
global-filleted-polyline-curves.lisp
lisp-mirror_gendl/surf/source/global-filleted-polyline-curves.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object global-filleted-polyline-curves (global-filleted-polyline) :documentation (:description "Produces a list of linear-curves and arc-curves which represent the straight sections and fillets of a global-filleted-polyline. Note also global-filleted-polyline-curve, which composes the segments together into a single curve." :examples "<pre> (in-package :gdl-user) (define-object test-global-filleted-polyline-curves (global-filleted-polyline-curves) :computed-slots ((default-radius 5) (vertex-list (list (make-point 0 0 0) (make-point 10 10 0) (make-point 30 10 0) (make-point 40 0 0) (make-point 30 -10 0) (make-point 10 -10 0) (make-point 0 0 0)))) :hidden-objects ((points :type 'point :sequence (:size (length (rest (the vertex-list)))) :center (nth (the-child index) (rest (the vertex-list)))) (view :type 'base-view :page-width (* 5 72) :page-height (* 5 72) :objects (cons self (list-elements (the points)))))) (generate-sample-drawing :objects (the-object (make-object 'test-global-filleted-polyline-curves)) :projection-direction (getf *standard-views* :trimetric)) </pre>") :computed-slots ((%lines-to-draw% (append-elements (the straight-curves) (the-element %lines-to-draw%))) (%curves-to-draw% (append (append-elements (the fillet-curves) (the-element %curves-to-draw%)))) ("List of GDL NURBS curve objects. The curve segments in the right order for chaining together." ordered-curves (let ((tail (nreverse (mapcan #'list (list-elements (the straight-curves)) (list-elements (the fillet-curves)))))) (if (< (the fillet-curves number-of-elements) (the straight-curves number-of-elements)) (cons (the straight-curves last) tail) tail))) (fillet-curve-types (let ((number-of-fillets (the fillets number-of-elements))) (unless (zerop number-of-fillets) (mapcar #'(lambda(fillet-index) (if (typep (the (fillets fillet-index)) 'geom-base::fillet) 'arc-curve 'null-part)) (list-of-numbers 0 (1- number-of-fillets))))))) :hidden-objects (("GDL Sequence of GDL NURBS curve objects. The arc-curves representing the fillets." fillet-curves :type (:sequence (the fillet-curve-types)) :sequence (:size (the fillets number-of-elements)) :pseudo-inputs (fillet) :fillet (the (fillets (the-child :index))) :radius (the-child fillet radius) :start-angle (the-child fillet start-angle-normalized) :end-angle (the-child fillet end-angle-normalized) :center (the-child fillet center) :orientation (the-child fillet orientation)) ("GDL Sequence of GDL NURBS curve objects. The linear-curves representing the straights." straight-curves :type 'linear-curve :sequence (:size (length (the straights))) ;; ;; FLAG clean up use of nth ;; :pseudo-inputs (pair) :pair (nth (the-child index) (the straights)) :start (second (the-child pair)) :end (first (the-child pair))))) (define-object global-filleted-polyline-curve (global-filleted-polyline-curves composed-curve) :documentation (:description "Provides a singular composed curve made from a global-filleted-polyline-curves object") :computed-slots ((curves (remove-if #'(lambda(item) (typep item 'null-part)) (the ordered-curves)))))
4,597
Common Lisp
.lisp
89
43.292135
134
0.669559
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
11d813a22f858276643ffea22c59aefce41046893a4652dc8febb504c1b65c43
35,822
[ -1 ]
35,823
approximated-subsurface.lisp
lisp-mirror_gendl/surf/source/approximated-subsurface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object approximated-subsurface (surface) :input-slots (surface-in curve-top curve-bottom curve-left curve-right (curve-top-uv (the %curve-top-dropped% uv-curve)) (curve-bottom-uv (the %curve-bottom-dropped% uv-curve)) (curve-left-uv (the %curve-left-dropped% uv-curve)) (curve-right-uv (the %curve-right-dropped% uv-curve)) (make-left-right-compatible? nil) (make-top-bottom-compatible? nil) ) :computed-slots ((native-surface (make-approximated-subsurface *geometry-kernel* :surface (the surface-in) :curve-top (the %curve-top-dropped%) :curve-bottom (the %curve-bottom-dropped%) :curve-left (the %curve-left-dropped%) :curve-right (the %curve-right-dropped%) :curve-top-uv (the curve-top-uv) :curve-bottom-uv (the curve-bottom-uv) :curve-left-uv (the curve-left-uv) :curve-right-uv (the curve-right-uv)))) :objects ((compatible-top-bottom :type (if (the make-top-bottom-compatible?) 'compatible-curves 'sequenced-curves) :curve-list (list (the curve-top) (the curve-bottom))) (compatible-left-right :type (if (the make-left-right-compatible?) 'compatible-curves 'sequenced-curves) :curve-list (list (the curve-left) (the curve-right))) (%curve-top-dropped% :type 'dropped-curve :curve-in (the compatible-top-bottom (curves 0)) :surface (the surface-in)) (%curve-bottom-dropped% :type 'dropped-curve :curve-in (the compatible-top-bottom (curves 1)) :surface (the surface-in)) (%curve-left-dropped% :type 'dropped-curve :curve-in (the compatible-left-right (curves 0)) :surface (the surface-in)) (%curve-right-dropped% :type 'dropped-curve :curve-in (the compatible-left-right (curves 1)) :surface (the surface-in)) ))
3,632
Common Lisp
.lisp
70
34.457143
92
0.529919
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
149c7612c04f58a799c9735bd3c1da6d13266ec40d2a8c744833cf22b6dbebbb
35,823
[ -1 ]
35,824
normalized-curve.lisp
lisp-mirror_gendl/surf/source/normalized-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object normalized-curve (curve) :documentation (:description "This object creates a new curve from an exiting curve by reasigning the lowest and highest parameter value of the underlying mathematical definition of the curve. This is a precise method, it does not change the curve geometry.") :input-slots ( ("GDL NURBS Curve. The curve to be normalized." curve-in) ("The lowest parameter value of the underlying mathematical definition for this parametric curve" u-min 0.0) ("The highest parameter value of the underlying mathematical definition for this parametric curve" u-max 1.0) (tolerance 0.0001)) :computed-slots ((native-curve (the curve-knots-interval-scaled native-curve ))) :hidden-objects ( ;;; ;;;it has to be made a new object for "curve-knots-remove" it is not used in this one. ;;; (curve-knots-remove :type 'curve :native-curve (tooccl *geometry-kernel* (the curve-in native-curve) :tolerance (the tolerance))) (curve-knots-interval-scaled :type 'curve :native-curve (curve-knot-scale *geometry-kernel* ;;(the curve-knots-remove copy native-curve) (the curve-in copy native-curve) :u-min (the u-min) :u-max (the u-max)))))
2,462
Common Lisp
.lisp
53
36.830189
90
0.644776
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e016b58f9f98d611634c7c8c10890f86ae48cb1f05e058e75f55b71ebdecb4db
35,824
[ -1 ]
35,825
edge-blend-surface.lisp
lisp-mirror_gendl/surf/source/edge-blend-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object edge-blend-surface (general-dual-blend-surface) :documentation (:description "Creates a smooth blend-surface between curve-1, lying on surface-1 and curve-2 on surface-2. Note that curve-1 and curve-2 have to be so-called on-surface curves, which means they must answer a uv-curve message which is the UV representation of the curve on the given surface. The most common way to establish an on-surface curve is to use an iso-curve to begin with, or to use a projected-curve or dropped-curve to ensure that the curve is indeed an on-surface curve. The local start and end directions of this surface at any point along curve-1 and curve-2 are determined from the cross-product between the tangent to the surface's u- or v-iso-curve (the one that is closest to being parallel to curve-1 or curve-2) at this point and the corresponding surface-normal at the same point. In this fashion a tangent blend is created between surface-1 and surface-2 that extends in a direction that follows and smoothly interpolates both surface's iso-curves. Takes the same inputs as general-dual-blend-surface, except for f-tangent-1 and f-tangent-2." :examples "<pre> (in-package :surf) (define-object test-e-b-s (base-object) :objects ((e-b-s :type 'edge-blend-surface :display-controls (list :color :green) :curve-side-1 :left-side :curve-side-2 :left-side :pass-down (curve-1 surface-1 curve-2 surface-2)) (surf-1-top :type 'linear-curve :hidden? t :start (make-point -5 -5 0) :end (make-point 5 -5 0)) (surf-1-bottom :type 'linear-curve :hidden? t :start (make-point -7 -10 -2) :end (make-point 7 -10 -2)) (surface-1 :type 'ruled-surface :curve-1 (the surf-1-top) :curve-2 (the surf-1-bottom)) (curve-1 :type 'iso-curve :display-controls (list :color :red :line-thickness 4) :surface (the surface-1) :parameter 0 :u-or-v :v) (surf-2-bottom :type 'linear-curve :hidden? t :start (make-point -5 5 0) :end (make-point 5 5 0)) (surf-2-top :type 'linear-curve :hidden? t :start (make-point -7 10 2) :end (make-point 7 10 2)) (surface-2 :type 'ruled-surface :curve-1 (the surf-2-bottom) :curve-2 (the surf-2-top)) (curve-2 :type 'iso-curve :display-controls (list :color :blue :line-thickness 4) :surface (the surface-2) :parameter 0 :u-or-v :v))) (generate-sample-drawing :object-roots (list (make-object 'test-e-b-s)) :projection-direction (getf *standard-views* :top)) </pre>") :input-slots (("Keyword. Used to specify the side w.r.t curve-1 in which the tangent blend-surface is to extend. Takes either :right-side or :left-side as input. Defaults to :right-side." curve-side-1 :right-side) ("Keyword. Used to specify the side w.r.t curve-2 in which the tangent blend-surface is to extend. Takes either :right-side or :left-side as input. Defaults to :right-side." curve-side-2 :right-side) ("GDL UV curve object. Defaults to the curve-1 uv-curve." curve-1-uv (the curve-1 uv-curve)) ("GDL UV curve object. Defaults to the curve-2 uv-curve." curve-2-uv (the curve-2 uv-curve)) (curve-1-u-or-v :u) (curve-1-accessor (ecase (the curve-1-u-or-v) (:u #'get-u) (:v #'get-v))) (curve-2-u-or-v :u) (curve-2-accessor (ecase (the curve-2-u-or-v) (:u #'get-u) (:v #'get-v)))) :computed-slots ( (f-tangent-1 #'(lambda(param) (let* (#+nil (surface-uv (the curve-1 (uv-curve (the surface-1)) (point param))) (surface-uv (the curve-1-uv (point param))) (surface-iso (make-object 'iso-curve :u-or-v (the curve-1-u-or-v) :surface (the surface-1) :parameter (funcall (the curve-1-accessor) surface-uv))) (tangent-accessor (if (eql (the curve-1-accessor) #'get-y) #'get-x #'get-y))) (ecase (the curve-side-1) (:right-side (the-object surface-iso (tangent (funcall tangent-accessor surface-uv)))) (:left-side (reverse-vector (the-object surface-iso (tangent (funcall tangent-accessor surface-uv))))))))) (f-tangent-2 #'(lambda(param) (let* ((surface-uv (the curve-2-uv (point param))) (surface-iso (make-object 'iso-curve :u-or-v (the curve-2-u-or-v) :surface (the surface-2) :parameter (funcall (the curve-2-accessor) surface-uv))) (tangent-accessor (if (eql (the curve-1-accessor) #'get-y) #'get-x #'get-y))) (ecase (the curve-side-2) (:right-side (the-object surface-iso (tangent (funcall tangent-accessor surface-uv)))) (:left-side (reverse-vector (the-object surface-iso (tangent (funcall tangent-accessor surface-uv)))))))))))
7,466
Common Lisp
.lisp
116
43.517241
582
0.539138
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5cfbd7fd67064809357fcd1dabe0f926f9808f1510964cb35ea5b1e7e454cc5a
35,825
[ -1 ]
35,826
trimmed-curve.lisp
lisp-mirror_gendl/surf/source/trimmed-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object trimmed-curve (curve) :documentation (:description "Creates a curve based on an existing curve but possibly with new start and end parameters (<tt>u1</tt> and <tt>u2</tt>)." :examples "<pre> (in-package :surf) (define-object test-trimmed-curve () :objects ((b-spline-curve :type 'b-spline-curve :control-points (list (make-point 0 0 0) (make-point 2 3.0 0.0) (make-point 4 2.0 0.0) (make-point 5 0.0 0.0) (make-point 4 -2.0 0.0) (make-point 2 -3.0 0.0) (make-point 0 0 0))) (trimmed-curve :type 'trimmed-curve :built-from (the b-spline-curve) :u1 0.2 :u2 0.8 :display-controls (list :color :red :line-thickness 1.5)))) (generate-sample-drawing :object-roots (make-object 'test-trimmed-curve)) </pre>" ) :input-slots ("GDL Curve Object. The underlying curve from which to build this curve." built-from ("Number. Specified start parameter. Defaults to the <tt>u1</tt> of the built-from." u1 (the built-from u1)) ("Number. Specified end parameter. Defaults to the <tt>u2</tt> of the built-from." u2 (the built-from u2)) ) :computed-slots ((native-curve-iw (cond ((null (the built-from)) (error "In trimmed-curve, you must specify a valid curve for the built-from.")) ((<= (the %u2%) (the %u1%)) (error "In ~s ~s (built-from ~s), u2 is not greater than u1. Cannot Trim." self (the strings-for-display) (the built-from))) (t (let ((native-curve-iw (iw-copy-curve *geometry-kernel* (the built-from native-curve-iw) :finalize? t ))) (let ((u-min (the built-from u-min)) (u-max (the built-from u-max)) (u1 (min (the %u1%) (the %u2%))) (u2 (max (the %u1%) (the %u2%)))) ;; ;; FLAG -- this error should never occur now. ;; (when (or (< u1 u-min) (> u2 u-max)) (error "Trim parameters out of range")) (iw-trim-curve *geometry-kernel* native-curve-iw u1 u2) native-curve-iw))))) (%u1% (progn (if (< (the u1) (the built-from u-min)) (progn (warn "Requested trim parameter ~a is less than the u-min of the original curve ~a. Pinning to the u-min value.~%" (the u1) (the built-from u-min)) (the built-from u-min)) (the u1)))) (%u2% (progn (if (> (the u2) (the built-from u-max)) (progn (warn "Requested trim parameter ~a is greater than the u-max of the original curve ~a. Pinning to the u-max value.~%" (the u2) (the built-from u-max)) (the built-from u-max)) (the u2)))) ("GDL Curve. The original untrimmed curve, same as the <tt>built-from.</tt>" basis (the built-from)))) (define-object test-trimmed-curve () :objects ((b-spline-curve :type 'b-spline-curve :control-points (list (make-point 0 0 0) (make-point 2 3.0 0.0) (make-point 4 2.0 0.0) (make-point 5 0.0 0.0) (make-point 4 -2.0 0.0) (make-point 2 -3.0 0.0) (make-point 0 0 0))) (trimmed-curve :type 'trimmed-curve :built-from (the b-spline-curve) :u1 0.2 :u2 0.8 :display-controls (list :color :red :line-thickness 1.5))))
5,495
Common Lisp
.lisp
99
35.767677
154
0.48262
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
31a3035ac7a597fd9189a243b3d684606ca6fc2f631033f5be45baa87b076d5b
35,826
[ -1 ]
35,827
curve.lisp
lisp-mirror_gendl/surf/source/curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (defstruct surface-point (parameter 0.0 :type double-float) (other-parameter 0.0 :type double-float) (uv-point nil #+allegro :type #+allegro (vector double-float)) (3d-point nil #+allegro :type #+allegro (vector double-float))) (defmethod get-parameter-of ((surface-point surface-point)) "Number. Returns the parameter component of a surface point." (surface-point-parameter surface-point)) (defmethod get-parameter-of ((surface-point t)) "Number. Returns the parameter component of a surface point." nil) (defmethod get-other-parameter-of ((surface-point surface-point)) "Number. Returns the other parameter component of a surface point." (surface-point-other-parameter surface-point)) (defmethod get-other-parameter-of ((surface-point t)) "Number. Returns the other parameter component of a surface point." nil) (defmethod get-3d-point-of ((surface-point surface-point)) "3D Point. Returns the 3D point component of a surface point." (surface-point-3d-point surface-point)) (defmethod get-3d-point-of ((surface-point t)) "3D Point. Returns the 3D point component of a surface point." nil) (defmethod get-uv-point-of ((surface-point surface-point)) "UV Point. Returns the UV (2D) point component of a surface point." (surface-point-uv-point surface-point)) (defmethod get-uv-point-of ((surface-point t)) "UV Point. Returns the UV (2D) point component of a surface point." nil) (defun get-point-on-surface (plist) "3D point. Returns the point found from a minimum or maximum distance computation involving a surface." (getf plist :point-on-surface)) (defun get-point-on-curve (plist) "3D point. Returns the point found from a minimum or maximum distance computation involving a curve." (getf plist :point-on-curve)) (defun get-point-on-other-curve (plist) "3D point. Returns the other point found from a minimum or maximum distance computation involving a curve." (getf plist :point-on-other-curve)) (define-object curve (geometry-kernel-object-mixin base-object) :documentation (:description "A generalized NURBS curve. Usually used as a mixin in more specific curves." :examples "<pre> (in-package :surf) (define-object test-curve (curve) :input-slots ((built-from (the curv-in))) :computed-slots ((control-pts (list (make-point 3 5 1) (make-point 5 8.0 1) (make-point 7 10.0 1) (make-point 8 5.0 1) (make-point 7 0.0 1) (make-point 5 0.0 1) (make-point 3 5 1)))) :hidden-objects ((curv-in :type 'b-spline-curve :control-points (the control-pts)))) (generate-sample-drawing :object-roots (make-object 'test-curve) :projection-direction :top) </pre>") :input-slots ((%decomposed?% nil) (%copy?% nil) (%reversed?% nil) (%derivative?% nil) (native-curve (when (the native-curve-iw) (get-nurbs-from-curve *geometry-kernel* (the native-curve-iw)))) ("GDL Curve object. The corresponding UV curve for the primary surface on which this curve lies, if any. If this is not a surface-curve, this will return an error." uv-curve (error "This curve is not on any surface")) (native-curve-iw (cond ((the built-from) (the built-from copy-new native-curve-iw)) ((null (the native-curve)) (error "No native-curve instantiated")) (t (make-b-spline-curve* *geometry-kernel* (the native-curve) :schedule-finalization? t)))) ("GDL Curve. Specify this if you want this curve to be a clone of an existing curve. (note - this uses a shared underlying curve object, it does not make a copy)" built-from nil) ;; ;; FLAG -- made this not be :defaulting anymore because tolerance ;; is not declared as trickle-down anywhere. ;; #+nil ("Number. Approximation tolerance for display purposes. Defaults to the tolerance of the built-from curve, if one exists, otherwise defaults to the *display-tolerance*." tolerance (if (the built-from) (the built-from tolerance) *display-tolerance*) :settable :defaulting) ("Number. Approximation tolerance for display purposes. Defaults to the tolerance of the built-from curve, if one exists, otherwise defaults to the *display-tolerance*." tolerance (if (the built-from) (the built-from tolerance) *display-tolerance*) :settable) (surf nil) (parameterization :inherited :settable) (nonrational-degree 3) (box-width (abs (- (get-x (first (the bounding-box))) (get-x (second (the bounding-box)))))) (box-length (abs (- (get-y (first (the bounding-box))) (get-y (second (the bounding-box)))))) (box-height (abs (- (get-z (first (the bounding-box))) (get-z (second (the bounding-box)))))) (tolerance-for-native-beziers (let ((tolerance (or (the tolerance) *display-tolerance*)) (adaptive1 (/ (the measure) 10.0)) (adaptive2 (* (the measure) 10.0)) (linear? (equal 2 (length (the weights))))) (cond (linear? tolerance) ((> (the measure) 100) adaptive1) ((< (the measure) .01) adaptive2) (t tolerance))))) :computed-slots ((measure (let ((tolerance (or (the tolerance) *display-tolerance*))) (* tolerance (curve-extent *geometry-kernel* (the native-curve))))) (b-spline-data-list (multiple-value-list (the b-spline-data))) (control-points (first (the b-spline-data-list))) (weights (second (the b-spline-data-list))) (knot-vector (third (the b-spline-data-list))) (degree (fourth (the b-spline-data-list))) (rational? (when (the weights) (not (every #'(lambda(weight) (near-to? weight 1.0)) (the weights))))) ("List of GDL surfaces. The surfaces on which this curve lies." on-surfaces nil) (uv-curves nil) ("Number. Equal to the natural <tt>u-min</tt> of the curve." u1 (the u-min)) ("Number. Equal to the natural <tt>u-max</tt> of the curve." u2 (the u-max)) (native-beziers (let ((beziers (with-error-handling (:error? t :timeout *nurbs-to-beziers-timeout*) (let ((native-curve (the native-curve)) (tolerance (when (or (the rational?) (/= (the degree) 3)) (the tolerance-for-native-beziers))) (nonrational-degree (the nonrational-degree)) (parameterization (the parameterization)) (maintain-end-tangents? nil)) (nurbs-to-beziers *geometry-kernel* native-curve tolerance nonrational-degree parameterization maintain-end-tangents? self (the rational?) :control-points-only? t))))) (make-array (length beziers) :initial-contents beziers))) (%lines-to-draw% (cond ((and (= (the degree) 1) (not (the rational?))) (let ((control-points (the b-spline-data))) (mapcar #'(lambda(start end) (list start end)) control-points (rest control-points)))) (*curve-tessellation?* (let ((points (the (equi-spaced-points (max 2 (floor (* (the total-length) ))))))) (mapcar #'list points (rest points)))) (t nil))) (%curves-to-draw% (unless (or *curve-tessellation?* (near-to? (the total-length) 0)) (if (typep self 'arc-curve) (call-next-method) (if (or (the %decomposed?%) (= (the %decomposed% curves number-of-elements) 1)) (unless (and (= (the degree) 1) (not (the rational?))) (when (list-elements (the beziers)) (let (result) (dolist (bezier (if t ;;*chain-beziers-for-display?* (chain-nurbs-curves (list-elements (the beziers))) (list-elements (the beziers))) result) (if (null result) (setq result (the-object bezier %curves-to-draw%)) (nconc result (the-object bezier %curves-to-draw%))))))) (append-elements (the %decomposed% curves) (the-element %curves-to-draw%)))))) ;;(closed? (coincident-point? (the start) (the end) :tolerance (the closed-tolerance))) (closed? (coincident-point? (the start) (the end))) ("Boolean. This will be t if the curve is generated successfully, nil otherwise." success? (when (the native-curve) t)) ("Number. The lowest parameter value of the underlying mathematical definition for this parametric curve" u-min (multiple-value-bind (min max) (the parameter-bounds) (declare (ignore max)) min)) ("Number. The highest parameter value of the underlying mathematical definition for this parametric curve" u-max (multiple-value-bind (min max) (the parameter-bounds) (declare (ignore min)) max)) ("3D Point. The point returned by evaluating the curve function at <tt>u1</tt>." start (the (point (the u1)))) ("3D Point. The point returned by evaluating the curve function at <tt>u2</tt>." end (the (point (the u2)))) ("3D Vector. The direction pointing from the start to the end." direction-vector (subtract-vectors (the end) (the start))) (first-derivative-native-curve (get-curve-first-derivative *geometry-kernel* (the native-curve))) (second-derivative-native-curve (get-curve-second-derivative *geometry-kernel* (the native-curve))) ;; ;; FLAG -- use the smlib method for this. ;; (bounding-box (bounding-box-from-points (the control-points))) (control-points-local (mapcar #'(lambda(point) (the (global-to-local point))) (the b-spline-data))) (%renderer-info% (list :vrml? t :view-default :trimetric)) (min-max-x-y-z (the %min-max-x-y-z%)) (face-curves (list :top (make-object 'linear-curve :start (the tight-box (vertex :top :front :left)) :end (the tight-box (vertex :top :rear :right))) :bottom (make-object 'linear-curve :start (the tight-box (vertex :bottom :front :left)) :end (the tight-box (vertex :bottom :rear :right))) :left (make-object 'linear-curve :start (the tight-box (vertex :left :bottom :front)) :end (the tight-box (vertex :left :top :rear))) :right (make-object 'linear-curve :start (the tight-box (vertex :right :bottom :front)) :end (the tight-box (vertex :right :top :rear))) :rear (make-object 'linear-curve :start (the tight-box (vertex :rear :left :bottom)) :end (the tight-box (vertex :rear :right :top))) :front (make-object 'linear-curve :start (the tight-box (vertex :front :left :bottom)) :end (the tight-box (vertex :front :right :top))))) ;; ;; FLAG -- get this from smlib. ;; (tight-box (the bounding-bbox)) ) :hidden-objects ( (%decomposed% :type (if (the %decomposed?%) 'null-decomposed-curves 'decomposed-curves) :curve-in self :tolerance (the tolerance) :tolerance-for-native-beziers (the tolerance-for-native-beziers)) ("GDL Curve. The first derivative of this curve. The degree will be one less than the degree of this curve." first-derivative :type (if (and (not (the %decomposed?%)) (not (the %copy?%)) (not (the %reversed?%)) (> (the degree) 1)) 'curve 'null-object) :%derivative?% t :native-curve (if (and (not (the %decomposed?%)) (not (the %copy?%)) (not (the %reversed?%)) (> (the degree) 1)) (the first-derivative-native-curve) nil)) ("GDL Curve. The second derivative of this curve. The degree will be two less than the degree of this curve." second-derivative :type (if (and (not (the %decomposed?%)) (not (the %copy?%)) (not (the %reversed?%)) (> (the degree) 2)) 'curve 'null-object) :%derivative?% t :native-curve (if (and (not (the %decomposed?%)) (not (the %copy?%)) (not (the %reversed?%)) (> (the degree) 2)) (the second-derivative-native-curve) nil)) (beziers :type 'bezier-curve :sequence (:size (length (the native-beziers))) :weights nil :knots nil :degree 3 :control-points (let ((result (aref (the native-beziers) (the-child index)))) (ecase (length result) (4 result) (3 (list (first result) (second result) (third result) (third result))) (2 (list (first result) (first result) (second result) (second result)))))) (reverse :type (if (or (the %copy?%) (the %decomposed?%) (the %reversed?%) (the %derivative?%)) 'null-object 'curve) :native-curve (curve-reverse *geometry-kernel* (the native-curve)) :%reversed?% t) (copy :type (if (or (the %reversed?%) (the %decomposed?%) (the %copy?%) (the %derivative?%)) 'null-object 'b-spline-curve) :%copy?% t :data (multiple-value-list (the b-spline-data)) :pseudo-inputs (data) :control-points (first (the-child data)) :weights (second (the-child data)) :knot-vector (third (the-child data)) :degree (fourth (the-child data)) )) :functions ( (%min-max-x-y-z% (&optional (tolerance *zero-epsilon*)) (flet ((min-max (accessor comparison) (min-max-search #'(lambda(param) (funcall accessor (the (point param)))) comparison (the u1) (the u2) tolerance))) (let ((min-x (min-max #'get-x #'<)) (max-x (min-max #'get-x #'>)) (min-y (min-max #'get-y #'<)) (max-y (min-max #'get-y #'>)) (min-z (min-max #'get-z #'<)) (max-z (min-max #'get-z #'>))) (list :min-x (the (point min-x)) :min-x-param min-x :max-x (the (point max-x)) :max-x-param max-x :min-y (the (point min-y)) :min-y-param min-y :max-y (the (point max-y)) :max-y-param max-y :min-z (the (point min-z)) :min-z-param min-z :max-z (the (point max-z)) :max-z-param max-z)))) ("Number. Returns the parameter of the given point on the curve. :arguments (point \"Point. The point of which the parameter should be calculated.\")" parameter-at-point (3d-point) (get-parameter-of (getf (the (minimum-distance-to-point 3d-point)) :point-on-curve))) (copy-new (&key (finalize? t)) (make-object 'curve :native-curve-iw (iw-copy-curve *geometry-kernel* (the native-curve-iw) :finalize? finalize?))) ("List of 3D points, List of numbers, List of numbers, and integer. Returns four values which are the control points, the weights, the knots, and the degree of the curve." b-spline-data () (get-curve-b-spline-data *geometry-kernel* (the native-curve))) ("3D Point. The point on the curve corresponding to the given parameter value. :arguments (parameter \"Number. The desired parameter to be evaluated on the curve.\")" point (parameter) (when (< parameter (the u-min)) (warn "~&Asked for point at parameter value ~a, but u-min of the curve is ~a, pinning to the u-min value.~%" parameter (the u-min)) (setq parameter (the u-min))) (when (> parameter (the u-max)) (warn "~&Asked for point at parameter value ~a, but u-max of the curve is ~a, pinning to the u-max value.~%" parameter (the u-max)) (setq parameter (the u-max))) (%get-point-on-curve *geometry-kernel* (the native-curve) parameter)) ("3D Vector. The curve tangent at the given parameter value. Supplementary values returned are: the 3D point at the parameter value. If keyword argument <tt>:include-curvature?</tt> is given as non-NIL, the radius of the osculating circle, the center for the osculating circle, the normal for the osculating circle, and the curve normal are also returned. Note: If <tt>:include-curvature?</tt> is given as non-NIL and the curve has no curvature at the specified parameter, NIL is returned for each of these four values. :arguments (parameter \"Number. The desired parameter to be evaluated on the curve.\") :&key ((include-curvature? nil) \"Boolean (T or NIL). Indicates whether to compute curvature information.\")" tangent (parameter &key include-curvature?) (if include-curvature? (get-curve-curvature *geometry-kernel* (the native-curve) parameter) (get-curve-tangent *geometry-kernel* (the native-curve) parameter))) ("Number. The radius of curvature (i.e. radius of the osculating circle) at the given parameter. :arguments (parameter \"Number. The parameter at which to compute radius of curvature\")" radius-of-curvature (parameter) (multiple-value-bind (tangent point radius) (the (tangent parameter :include-curvature? t)) (declare (ignore tangent point)) radius)) ("3D Vector. The normal of the curve at the given parameter value, i.e. the vector pointing from the point on the curve at this parameter to the center of the osculating circle at that point. if the curve has no curvature at the given parameter, NIL is returned. :arguments (parameter \"Number. The desired parameter to be evaluated on the curve.\")" normal (parameter) (multiple-value-bind (tangent point radius center circle-normal curve-normal) (the (tangent parameter :include-curvature? t)) (declare (ignore tangent point radius center circle-normal)) curve-normal)) ("3D Vector. The given parameter evaluated on the second derivative curve of this curve. Note that this is only valid if this curve has degree of at least two (2), and will throw an error otherwise. :arguments (parameter \"Number. The desired parameter to be evaluated on the second derivative curve.\")" acceleration (parameter) (the second-derivative (point parameter))) ("Numbers (multiple return values). The minimum and maximum parameter values for this parametric curve." parameter-bounds () (get-curve-parameter-bounds *geometry-kernel* (the native-curve))) ("Number. The total length of the curve from given start-parameter to given end-parameter. :&key ((u1 (the u1)) \"Number. The start parameter for computing the length\" (u2 (the u2)) \"Number. The end parameter for computing the length\" (tolerance 0.01) \"Number. The tolerance (absolute or relative to curve extent) for computing the length\" (tolerance-type :relative) \"Keyword Symbol, :relative or :absolute. The type of the specified tolerance\")" total-length (&key (u1 (the u1)) (u2 (the u2)) (tolerance 0.01) (tolerance-type :relative)) (get-curve-total-length *geometry-kernel* self u1 u2 tolerance tolerance-type)) ("List of 3D Points. Returns the specified number of points equally spaced along the curve. :arguments (number \"Number. How many points to return.\") :&key ((spacing :arc-length) \"Keyword Symbol, :parametric or :arc-length. Defaults to :arc-length.\" (arc-length-approximation-tolerance *zero-epsilon*) \"Number. A smaller number gives tighter arc length approximation. Scaled to curve exent.\")" equi-spaced-points (number &key (spacing :arc-length) (arc-length-approximation-tolerance *zero-epsilon*) (u1 (the u1)) (u2 (the u2)) (parameter-list (when (eql spacing :parametric) (list-of-numbers u1 u2 (/ (- u2 u1) (1- number))))) (percentage-list (when (eql spacing :arc-length) (list-of-numbers 0 1 (/ (1- number)))))) (unless (> number 1) (error "Equi-spaced-points must be called with a number greater than 1.")) (case spacing (:parametric (mapcar #'(lambda(parameter) (the (point parameter))) parameter-list)) (:arc-length (mapcar #'(lambda(percentage) (the (point-at-arc-length percentage :tolerance arc-length-approximation-tolerance))) percentage-list)) (otherwise (error "For equi-spaced-points, only :parametric and :arc-length spacing are currently implemented.")))) ("Number. Returns the parameter representing a point offset from the start of the curve by the given length. :arguments (distance \"Number. The arc length from the start.\")" parameter-at-length (distance) (get-offset-point-along *geometry-kernel* self (the u-min) distance)) ("Surface point. Returns point at given parameter offset by given distance. :arguments (curve-parameter \"Number. The curve parameter to start from\" distance \"Number. The distance to offset\")" offset-point-along (curve-parameter distance) (let ((parameter (get-offset-point-along *geometry-kernel* self curve-parameter distance))) (make-surface-point :parameter parameter :3d-point (the (point parameter))))) (point-at-arc-length (percentage &key (tolerance *zero-epsilon*)) (get-point-at-arc-length *geometry-kernel* (the native-curve) percentage :tolerance tolerance)) ("List of Numbers. Returns the specified number of parameters equally spaced along the curve. :arguments (number \"Number. How many parameters to return.\") :&key ((spacing :arc-length) \"Keyword Symbol, :parametric or :arc-length. :arc-length is the default\")" equi-spaced-parameters (number &key (spacing :arc-length)) (unless (member spacing '(:parametric :arc-length)) (error "For equi-spaced-parameters, only :parametric and :arc-length spacing are currently implemented.")) (unless (> number 1) (error "Equi-spaced-parameters must be called with a number greater than 1.")) (ecase spacing (:parametric (let ((u1 (the u1)) (u2 (the u2))) (list-of-numbers u1 u2 (/ (- u2 u1) (1- number))))) (:arc-length (let ((percentage-list (list-of-numbers 0 1 (/ (1- number))))) (mapcar #'(lambda(percentage) (second (multiple-value-list (the (point-at-arc-length percentage))))) percentage-list))))) ("Returns a bbox object, answering xmin, ymin, zmin, xmax, ymax, and zmax, for a box containing the convex hull (i.e. the control points) of this curve and oriented according to the given <tt>center</tt> and <tt>orientation</tt>." local-bounding-box (center orientation) (let* ((object (make-object 'base-object :center center :orientation orientation)) (points (mapcar #'(lambda(point) (the-object object (global-to-local point))) (the b-spline-data)))) (let ((xmax (apply #'max (mapcar #'get-x points))) (ymax (apply #'max (mapcar #'get-y points))) (zmax (apply #'max (mapcar #'get-z points))) (xmin (apply #'min (mapcar #'get-x points))) (ymin (apply #'min (mapcar #'get-y points))) (zmin (apply #'min (mapcar #'get-z points)))) (make-object 'bbox :xmax xmax :ymax ymax :zmax zmax :xmin xmin :ymin ymin :zmin zmin)))) ("Boolean. Given a point and a vector defining a plane, returns T or NIL depending whether this curve lies in the plane. Also returns a second value which is the maximum distance of the curve from the plane. :arguments (plane-point \"3d-point. Point on the plane\" plane-normal \"3d-vector. Normal vector of the plane\") :&key ((distance-tolerance *3d-tolerance-default*) \"Number. Allowed distance of any point on the curve from the plane.\")" in-plane? (plane-point plane-normal &key (distance-tolerance *3d-tolerance-default*)) (curve-on-plane? *geometry-kernel* self plane-point plane-normal :distance-tolerance distance-tolerance)) ("Boolean. Returns non-NIL if the given parameter lies within the parameter range of this curve. :arguments (parameter \"Number. The parameter to be tested.\")" on? (parameter) (<= (the u-min) parameter (the u-max))) ("GDL Curve object. Returns a curve which is trimmed from parameter-1 to parameter-2. :arguments (parameter-1 \"Number. The start parameter\" parameter-2 \"Number. The end parameter\")" trim (parameter-1 parameter-2) (make-object 'trimmed-curve :built-from self :u1 parameter-1 :u2 parameter-2)) ("Surface Point. Given a 3D point, returns the point(s) projected normally onto the curve. :&key ((distance-tolerance [covers entire curve]) \"Number. The 3D point must be within this distance of the curve for a successful drop.\")" dropped-point (3d-point &key (distance-tolerance (let ((control-points (the b-spline-data))) (apply #'max (mapcar #'(lambda(point) (3d-distance 3d-point point)) control-points))))) (let ((parameter (get-curve-dropped-point *geometry-kernel* self 3d-point :distance-tolerance distance-tolerance))) (when parameter (make-surface-point :parameter parameter :3d-point (the (point parameter)))))) ("Surface Points. Points of intersection between this curve and another curve. This function also returns a second value, which is a list of surface points representing the ends of contiguous segments, if any, associated with the surface point in the same position in the primary returned list. NIL values in this second returned list indicate that there was no contiguous segment, only an intersecting point as indicated by the surface point in the primary returned list. :arguments (other-curve \"GDL Curve. The curve with which to intersect.\") :&key ((distance-tolerance *3d-tolerance-default*) \"Number. Distance for two points to be considered coincident.\") :note use <tt>get-parameter-of</tt>, <tt>get-3d-point-of</tt>, and <tt>get-uv-point-of</tt> to extract components of a surface point." curve-intersection-points (other-curve &key (distance-tolerance *3d-tolerance-default*)) (multiple-value-bind (starts ends) (get-curve-curve-intersection-point *geometry-kernel* self other-curve :distance-tolerance distance-tolerance) (let ((pairs (sort (mapcar #'list starts ends) #'< :key #'(lambda(list) (first (first list)))))) (values (mapcar #'(lambda(pair) (let ((parameter (first pair))) (make-surface-point :parameter (first parameter) :other-parameter (second parameter) :3d-point (the (point (first parameter)))))) pairs) (mapcar #'(lambda(pair) (let ((parameter (when (> (first (second pair)) (first (first pair))) (second pair)))) (when parameter (make-surface-point :parameter (first parameter) :other-parameter (second parameter) :3d-point (the (point (first parameter))))))) pairs))))) ("Surface point. Returns the first point of intersection between this curve and the surface given as an argument. :arguments (surface \"GDL Surface object. The surface to intersect with this curve.\") :&key ((3d-tolerance *3d-tolerance-default*) \"Number. The tolerance to use for intersecting.\")" surface-intersection-point (surface &key (3d-tolerance *3d-tolerance-default*)) (let ((triplet (first (get-surface-curve-intersection-points *geometry-kernel* surface self :3d-tolerance 3d-tolerance)))) (when triplet (make-surface-point :parameter (first triplet) :uv-point (make-point (second triplet) (third triplet)) :3d-point (the (point (first triplet))))))) ("List of Surface points. Returns the point(s) of intersection between this curve and the surface given as an argument. :arguments (surface \"GDL Surface object. The surface to intersect with this curve.\") :&key ((3d-tolerance *3d-tolerance-default*) \"Number. The tolerance to use for intersecting.\")" surface-intersection-points (surface &key (3d-tolerance *3d-tolerance-default*)) (let ((triplets (get-surface-curve-intersection-points *geometry-kernel* surface self :3d-tolerance 3d-tolerance))) (mapcar #'(lambda(triplet) (make-surface-point :parameter (first triplet) :uv-point (make-point (second triplet) (third triplet)) :3d-point (the (point (first triplet))))) triplets))) ("Surface Point. First point of intersection between this curve and the other curve given as the argument. This function also returns a second value, which is a surface point representing the end of a contiguous segment, if any, associated with the surface point given as the primary return value. A NIL value as this second return value indicates that there was no contiguous segment, only an intersecting point as indicated by the surface point given as the primary return value. :arguments (other-curve \"GDL Curve. The curve with which to intersect.\") :&key ((distance-tolerance *3d-tolerance-default*) \"Number. Distance for two points to be considered coincident.\") :note use <tt>get-parameter-of</tt> and <tt>get-3d-point-of</tt> to extract components of a surface point." curve-intersection-point (other-curve &key (distance-tolerance *3d-tolerance-default*)) (multiple-value-bind (starts ends) (the (curve-intersection-points other-curve :distance-tolerance distance-tolerance)) (values (first starts) (first ends)))) ("Number. The minimum radius of curvature for the curve. A second value is also returned, which is a surface point indicating the point on the curve where this minimum radius occurs. A third value is also returned, which is a list of additional curve parameters where similar minimum radii occur." minimum-radius () (let ((parameters (get-curve-minimum-radius *geometry-kernel* self))) (values (the (radius-of-curvature (first parameters))) (make-surface-point :parameter (first parameters) :3d-point (the (point (first parameters)))) (rest parameters)))) ("Surface Points. Points of intersection between this curve and the plane denoted by plane-point and plane-normal. :note use <tt>get-parameter-of</tt> and <tt>get-3d-point-of</tt> to extract components of a surface point." plane-intersection-points (plane-point plane-normal) (let ((parameters (sort (get-curve-plane-intersection-point *geometry-kernel* self plane-point (unitize-vector plane-normal)) #'<))) (mapcar #'(lambda(parameter) (make-surface-point :parameter parameter :3d-point (the (point parameter)))) parameters))) ("Surface Point. First point of intersection between this curve and the plane denoted by plane-point and plane-normal :note use <tt>get-parameter-of</tt> and <tt>get-3d-point-of</tt> to extract components of a surface point." plane-intersection-point (plane-point plane-normal) (first (the (plane-intersection-points plane-point plane-normal)))) ("Either T or a plist of numbers with keys <tt>:distance</tt>, <tt>angle</tt>, <tt>:length</tt>. :&key ((3d-tolerance *3d-tolerance-default*) \"Allowed maximum distance between curve segments.\" (angle-tolerance *angle-tolerance-default) \"Allowed maximum angle in radians between end/start tangents of curve segments.\" (minimum-segment-length *minimum-segment-length-default*) \"Allowed minimum curve segment length.\")" check-continuity (&key (3d-tolerance *3d-tolerance-default*) (angle-tolerance *angle-tolerance-radians-default*) (minimum-segment-length *minimum-segment-length-default*)) (let ((decomposed (list-elements (the %decomposed%)))) (let ((result (list :distance nil :angle nil :length nil))) (mapc #'(lambda(c1 c2) (let ((tan1 (the-object c1 (tangent (the-object c1 u-max)))) (tan2 (the-object c2 (tangent (the-object c2 u-min))))) (let ((angle (angle-between-vectors tan1 tan2)) (current (getf result :angle))) (when (and (> angle angle-tolerance) (or (null current) (> angle current))) (setf (getf result :angle) angle)))) (let ((distance (3d-distance (the-object c1 end) (the-object c2 start))) (current (getf result :distance))) (when (and (> distance 3d-tolerance) (or (null current) (> distance current))) (setf (getf result :distance) distance))) (let ((length (the-object c1 total-length)) (current (getf result :length))) (when (and (< length minimum-segment-length) (or (null current) (< length current))) (setf (getf result :length) length)))) (if (the closed?) (append decomposed (list (first decomposed))) decomposed) (if (the closed?) (rest (append decomposed (list (first decomposed)))) (rest decomposed))) (if (and (null (getf result :distance)) (null (getf result :angle)) (null (getf result :length))) t result)))) ("Keyword symbol, :closed, :open, or :continuous. :continuous if ends are within <tt>*3d-tolerance-default*</tt> and tangents are within <tt>*angle-tolerance-default*</tt>, :closed if ends are within <tt>*3d-tolerance-default*</tt> but tangents are not within <tt>*angle-tolerance-default*</tt>, and :open if ends are not within <tt>*3d-tolerance-default*</tt>." closure () (cond ((and (coincident-point? (the start) (the end) :tolerance *3d-tolerance-default*) (let ((tan1 (the (tangent (the u-max)))) (tan2 (the (tangent (the u-min))))) (< (angle-between-vectors tan1 tan2) *angle-tolerance-radians-default*))) :continuous) ((coincident-point? (the start) (the end) :tolerance *3d-tolerance-default*) :closed) (t :open))) ("Number. The reciprocal of the radius of curvature at the given parameter." curvature (parameter) (/ (the (radius-of-curvature parameter)))) ("Plist. The returned plist contains information about the minimum distance from this curve to the point given as the argument. :arguments (point \"3D Point\")" minimum-distance-to-point (point &key (distance-tolerance 10000)) (the (point-solve point :minimize :distance-tolerance distance-tolerance))) ("Plist. The returned plist contains information about the maximum distance from this curve to the point given as the argument. :arguments (point \"3D Point\")" maximum-distance-to-point (point &key (distance-tolerance 10000)) (the (point-solve point :maximize :distance-tolerance distance-tolerance))) (point-solve (point operation &key (distance-tolerance 10000)) (let ((parameter (first (global-curve-point-solve *geometry-kernel* self :point point :operation-type operation :distance-tolerance distance-tolerance)))) (let* ((point-on-curve (when parameter (make-surface-point :parameter parameter :3d-point (the (point parameter))))) (distance (when point-on-curve (3d-distance (get-3d-point-of point-on-curve) point)))) (list :point-on-curve point-on-curve :distance distance)))) ("List of Plists. The returned list of plists contains information about the points where the tangents of this curve and those of the curve given as the argument are equal. :arguments (curve \"GDL Curve object\")" dropped-curve (curve) (the (curve-solves curve :normalize))) ("List of Plists. The returned list of plists contains information about the points where the tangents of this curve and the vector given as the argument are equal. :arguments (vector \"GDL Vector\")" tangent-points (vector) (the (curve-solves (make-object 'linear-curve :start (make-point 0 0 0) :end vector) :normalize))) ("Plist. The returned plist contains information about the minimum distance from this curve to the curve given as the argument. :arguments (curve \"GDL Curve object\")" minimum-distance-to-curve (curve) (the (curve-solve curve :minimize))) ("Plist. The returned plist contains information about the maximum distance from this curve to the curve given as the argument. :arguments (curve \"GDL Curve object\")" maximum-distance-to-curve (curve) (the (curve-solve curve :maximize))) (curve-solves (curve operation) (let (result) (dolist (solution (global-curve-solve *geometry-kernel* self :other-curve curve :operation-type operation) (nreverse result)) (destructuring-bind (parameter other-parameter) solution (let ((point-on-curve (when parameter (make-surface-point :parameter parameter :3d-point (the (point parameter))))) (point-on-other-curve (when other-parameter (make-surface-point :parameter other-parameter :3d-point (the-object curve (point other-parameter)))))) (let ((distance (when (and point-on-curve point-on-other-curve) (3d-distance (get-3d-point-of point-on-curve) (get-3d-point-of point-on-other-curve))))) (push (list :point-on-curve point-on-curve :point-on-other-curve point-on-other-curve :distance distance) result))))))) (curve-solve (curve operation) (destructuring-bind (parameter other-parameter) (first (global-curve-solve *geometry-kernel* self :other-curve curve :operation-type operation)) (let ((point-on-curve (when parameter (make-surface-point :parameter parameter :3d-point (the (point parameter))))) (point-on-other-curve (when other-parameter (make-surface-point :parameter other-parameter :3d-point (the-object curve (point other-parameter)))))) (let ((distance (when (and point-on-curve point-on-other-curve) (3d-distance (get-3d-point-of point-on-curve) (get-3d-point-of point-on-other-curve))))) (list :point-on-curve point-on-curve :point-on-other-curve point-on-other-curve :distance distance))))))) (define-object null-decomposed-curves (null-object) :objects ((curves :type 'null-object :sequence (:size 0))))
41,510
Common Lisp
.lisp
633
53.758294
164
0.631875
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
75e707b68c0c27bc80a22698c868e8514e36e0b8d2e71db8c808534a1d341bcf
35,827
[ -1 ]
35,828
vertex.lisp
lisp-mirror_gendl/surf/source/vertex.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object vertex (base-object) :input-slots (%native-vertex% %native-brep% ;; FLAG -- should default to get-brep-from-face of the %native-face%. brep ;; FLAG -- should default to a new brep constructed from the %native-brep% ) :computed-slots ((center (get-3d-point-from-vertex *geometry-kernel* (the %native-vertex%)))))
1,301
Common Lisp
.lisp
27
42.777778
100
0.705977
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
160c6a55fa20af3a95e2a3b641efe316bd62c7aaedf078792f8d3f8dfa284252
35,828
[ -1 ]
35,829
poly-brep.lisp
lisp-mirror_gendl/surf/source/poly-brep.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object poly-brep (geometry-kernel-object-mixin base-object) :documentation (:description "A polygonal representation for a boundary representation geometric entity.") :input-slots (brep max-chord-height max-angle-degrees max-3d-edge max-aspect-ratio smooth-results? (native-pointer nil) ) :computed-slots ((%lines-to-draw% (let* ((poly-brep-data (the mesh-data)) (vertex-counts (getf poly-brep-data :vertex-counts)) (vertex-indices (coerce (getf poly-brep-data :vertex-indices) 'vector)) (3d-points (coerce (getf poly-brep-data :3d-points) 'vector)) (total 0)) (mapcan #'(lambda(count) (let ((indices (subseq vertex-indices total (+ total count)))) (let ((result (append (map 'list #'(lambda(p1 p2) (list p1 p2)) (map 'list #'(lambda(index) (svref 3d-points index)) indices) (map 'list #'(lambda(index) (svref 3d-points index)) (subseq indices 1))) (list (list (svref 3d-points (svref indices (1- count))) (svref 3d-points (svref indices 0))))))) (incf total count) result))) vertex-counts))) ("Plist. Contains mesh data from the poly brep." mesh-data (the get-brep-mesh)) (%native-poly-brep% (or (the native-pointer) (make-poly-brep *geometry-kernel* (the brep %native-brep%) :dCHTol (the max-chord-height) :dCrvTessAngle (the max-angle-degrees) :dSrfTessAngle (the max-angle-degrees) :dMax3DEdge (the max-3d-edge) :dMaxAspect (the max-aspect-ratio) :bSmoothResults (if (the smooth-results?) 1 0))))) :functions ((get-brep-mesh () (poly-brep-get-brep-mesh *geometry-kernel* (the %native-poly-brep%))) (write-stl-file (file-name &key (format :ascii)) (poly-brep-write-to-stl-file *geometry-kernel* (the %native-poly-brep%) file-name format))))
3,852
Common Lisp
.lisp
67
36.41791
109
0.49394
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a2f349f45b5adc2b2a78d708bb3a7f51320ac4c65d13318673361aabbc717e66
35,829
[ -1 ]
35,830
conic-curve.lisp
lisp-mirror_gendl/surf/source/conic-curve.lisp
;; ;; Copyright 2014 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object conic-curve (curve) :documentation (:description "A curve constructed from conic inputs. Inputs are two endpoints, two end tangents, and a point on the curve." :examples "<pre> (in-package :gdl-user) (define-object conic-curve-test (conic-curve) :computed-slots ((start-point (make-point -10 0 0)) (start-tangent (make-point 0.1 1 0)) (end-point (make-point 10 0 0)) (end-tangent (make-point -0.1 1 0)) (point-on-curve (make-point 0 12 0)))) (generate-sample-drawing :objects (make-object 'conic-curve-test)) </pre>") :input-slots ("3D Point. Start Point" start-point "3D Vector. Start Tangent" start-tangent "3D Point. End Point" end-point "3D Vector. End Tangent" end-tangent "3D Point. A point on the curve." point-on-curve) :computed-slots ((native-curve (funcall (symbol-function (read-from-string "smlib::make-conic-curve")) *geometry-kernel* (the start-point) (the start-tangent) (the end-point) (the end-tangent) (the point-on-curve))))) (eval-when (:compile-toplevel :load-toplevel :execute) (export 'conic-curve))
2,043
Common Lisp
.lisp
55
33.345455
114
0.714432
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
cc8c549f260ade32bdd330fa57e425dd8aa50cdffca6e2b9f6f9c0d7c7f177b9
35,830
[ -1 ]
35,831
decomposed-curves.lisp
lisp-mirror_gendl/surf/source/decomposed-curves.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object decomposed-curves (base-object) :documentation (:description "Given an input curve, creates a sequence of curve segments that do not contain knots with degree-fold mutiplicity." :examples "<pre> (in-package :surf) (define-object test-global-filleted-polyline-curves (global-filleted-polyline-curves) :computed-slots ((default-radius 5) (vertex-list (list (make-point 0 0 0) (make-point 10 10 0) (make-point 30 10 0) (make-point 40 0 0) (make-point 30 -10 0) (make-point 10 -10 0) (make-point 0 0 0)))) :hidden-objects ((points :type 'point :sequence (:size (length (rest (the vertex-list)))) :center (nth (the-child index) (rest (the vertex-list)))))) (define-object test-composed-curve (composed-curve) :computed-slots ((curves (the filleted-polyline-curves ordered-curves))) :hidden-objects ((filleted-polyline-curves :type 'test-global-filleted-polyline-curves))) (define-object test-decomposed-curves (decomposed-curves) :computed-slots ((curve-in (the composed-curve))) :objects ((composed-curve :type 'test-composed-curve))) (generate-sample-drawing :object-roots (make-object 'test-decomposed-curves)) </pre>") :input-slots ("GDL Curve. Curve (presumably multi-segment) to be decomposed." curve-in (tolerance-for-native-beziers (the curve-in tolerance-for-native-beziers)) (tolerance (the curve-in tolerance)) ) :computed-slots ((%decomposed-native-curves% (decomposed-curves *geometry-kernel* (the curve-in native-curve)))) :objects (("Sequence of GDL curve objects. The resulting segment curves after decomposition." curves :type 'curve :%decomposed?% t :sequence (:size (length (the %decomposed-native-curves%))) :tolerance (the tolerance) :tolerance-for-native-beziers (the tolerance-for-native-beziers) :native-curve (nth (the-child index) (the %decomposed-native-curves%))))) ;; (define-object test-decomposed-curves (decomposed-curves) ;; :computed-slots ;; ((curve-in (the composed-curve))) ;; ;; :objects ((composed-curve :type 'test-composed-curve)))
3,165
Common Lisp
.lisp
72
38.458333
111
0.698617
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c7198ace913431e8d09ca0db06d353b05fd00b503ca4494fe6f2e21135030460
35,831
[ -1 ]
35,832
normally-projected-curve.lisp
lisp-mirror_gendl/surf/source/normally-projected-curve.lisp
(in-package :surf) (define-object normally-projected-curve (curve) :input-slots (from-surface curve to-surface (number-of-points 200)) :computed-slots ((sample-points (the curve uv-curve (equi-spaced-points (the number-of-points)))) (normals (mapcar #'(lambda(point) (the from-surface (normal (get-u point) (get-v point)))) (the sample-points))) (projected-points (mapcar #'(lambda(point normal) (the to-surface (projected-point (the from-surface (point (get-u point) (get-v point))) normal))) (the sample-points) (the normals))) (projected-points-3d (mapcar #'get-3d-point-of (the projected-points))) (projected-points-uv (mapcar #'get-uv-point-of (the projected-points))) (built-from (the fitted-3d))) :hidden-objects ((fitted :type 'fitted-curve :points (the projected-points-3d)) (fitted-uv :type 'fitted-curve :points (mapcar #'(lambda(point) (make-point (get-x point) (get-y point) 0)) (the projected-points-uv))) (approximated :type 'approximated-curve :curve-in (the fitted-uv) :tolerance 0.00001) (fitted-3d :type 'b-spline-curve :knot-vector (the approximated knot-vector) :degree (the approximated degree) :weights (the approximated weights) :control-points (mapcar #'(lambda(point) (the to-surface (point (get-u point) (get-v point)))) (the approximated control-points))))) ;; ;; FLAG -- add to regression tests. ;; #+nil (define-object normally-projected-curve-test (normally-projected-curve) :computed-slots ((from-surface (the test-fitted-surface)) (curve (the projected)) (to-surface (the offset-surface))) :objects ((test-fitted-surface :type 'test-fitted-surface :grid-height 1) (offset-surface :type 'rectangular-surface :length 5 :width 5 :center (make-point 2 2 1.5)) (projected :type 'projected-curve :curve-in (the segment) :surface (the test-fitted-surface) :projection-vector (the (face-normal-vector :bottom))) (segment :type 'linear-curve :start (make-point 1 1 3) :end (make-point 3 3 3))))
2,203
Common Lisp
.lisp
46
40.717391
119
0.663512
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f85d7597fea3a63018363695143ce1162c74795a62c53a8541d462eb559c8dac
35,832
[ -1 ]
35,833
revolved-surface.lisp
lisp-mirror_gendl/surf/source/revolved-surface.lisp
; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object revolved-surface (brep surface) :documentation (:description "Creates a surface of revolution based on an arbitrary NURBS curve revolved by some angle about a central axis and axis point." :examples "<pre> (in-package :surf) (define-object test-revolved-surface (revolved-surface) :computed-slots ((display-controls (list :color :green-yellow2))) :hidden-objects ((curve :type 'arc-curve :center (translate (the center) :right 50) :orientation (alignment :top (the (face-normal-vector :rear))) :start-angle (half pi) :end-angle (* 3/2 pi) :radius 10))) (generate-sample-drawing :objects (make-object 'test-revolved-surface) :projection-direction :trimetric) </pre>") :computed-slots (;;(%native-brep% (the sewn-brep %native-brep%)) (%native-brep% (the components brep %native-brep%)) (native-surface (if (eql (the components number-of-elements) 1) (the (components 0) native-surface) (error "Revolved-surface, when given a multiple-component curve, is a brep which contains a sequence of faces. It is not an actual surface itself. If given a single-component curve, revolved-surface will be a surface as well as a containing brep.")))) :input-slots ((center (make-point 0 0 0) :defaulting) "GDL Curve object. The profile to be revolved." curve ("3D Point. The center of revolution. Default value is the <tt>center</tt>." axis-point (the center)) ("3D Vector. The direction of axis of revolution. Default is the top of the reference box." axis-vector (the (face-normal-vector :top))) ("Angle in radians. The amount to revolve. Default is twice pi (a full circle of revolution)." arc 2pi)) :hidden-objects ((decomposed :type 'decomposed-curves :curve-in (the curve)) (components :type 'single-revolved-surface :sequence (:size 1) :pass-down (curve axis-point axis-vector arc)))) (define-object single-revolved-surface (surface) :input-slots (curve (axis-point (the center)) (axis-vector (the (face-normal-vector :top))) (arc 2pi)) :computed-slots ((native-surface (make-revolved-surface *geometry-kernel* :curve (the curve native-curve) :axis-point (the axis-point) :axis-vector (the axis-vector) :arc (radians-to-degrees (the arc)) :flag 2)))) (define-object revolved-surfaces (base-object) :documentation (:description "Creates a set of surfaces of revolution based on a list of arbitrary NURBS curves revolved by some angle about a central axis and axis point." :examples "<pre> (in-package :gdl-user) (define-object test-revolved-surfaces (revolved-surfaces) :computed-slots ((curves (list (the curve-1) (the curve-2)))) :hidden-objects ((curve-1 :type 'arc-curve :center (translate (the center) :right 50) :orientation (alignment :top (the (face-normal-vector :rear))) :start-angle 0 :end-angle (/ pi 4) :radius 10) (curve-2 :type 'arc-curve :center (translate (the center) :right 50) :orientation (alignment :top (the (face-normal-vector :rear))) :start-angle pi :end-angle (* 5/4 pi) :radius 10) (view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :page-width (* 5 72) :page-length (* 5 72) :object-roots (list self)))) (generate-sample-drawing :objects (list-elements (the-object (make-object 'test-revolved-surfaces) surfaces)) :projection-direction :trimetric) </pre>") :input-slots ("List of GDL Curve objects. The profiles to be revolved." curves ("3D Point. The center of revolution. Default value is the <tt>center</tt>." axis-point (the center)) ("3D Vector. The direction of axis of revolution. Default is the top of the reference box." axis-vector (the (face-normal-vector :top))) ("Angle in radians. The amount to revolve. Default is twice pi (a full circle of revolution)." arc 2pi)) :objects (("Sequence of GDL Surfaces. The resultant revolved surfaces." surfaces :type 'single-revolved-surface :sequence (:size (length (the curves))) :curve (nth (the-child index) (the curves)) :pass-down (axis-point axis-vector arc))))
5,940
Common Lisp
.lisp
115
40.182609
143
0.627076
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
048aff783db572be094c8cbda91f3c63382ed8cef6b3af75e9df6ccb350048f3
35,833
[ -1 ]
35,834
box-solid.lisp
lisp-mirror_gendl/surf/source/box-solid.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object box-solid (brep box) :documentation (:description "A rectangular box represented as a brep solid. Contains the union of messages (e.g. input-slots, computed-slots, etc) from brep and box." :examples "<pre> (in-package :surf) (define-object test-box-solid (box-solid) :computed-slots ((length 10) (width 20) (height 30))) (generate-sample-drawing :objects (the-object (make-object 'test-box-solid) ) :projection-direction (getf *standard-views* :trimetric)) </pre>") :computed-slots ( ;; ;; FLAG -- should be able to call to base-object's version of this instead of repeating code here. ;; (local-box (let ((vertices (let (vertices) (dolist (lateral '(:left :right) vertices) (dolist (longitudinal '(:front :rear)) (dolist (vertical '(:bottom :top)) (push (the (vertex lateral longitudinal vertical)) vertices))))))) (let (xmin ymin zmin xmax ymax zmax) (mapc #'(lambda(vertex) (let ((x (get-x vertex)) (y (get-y vertex)) (z (get-z vertex))) (when (or (null xmin) (< x xmin)) (setq xmin x)) (when (or (null xmax) (> x xmax)) (setq xmax x)) (when (or (null ymin) (< y ymin)) (setq ymin y)) (when (or (null ymax) (> y ymax)) (setq ymax y)) (when (or (null zmin) (< z zmin)) (setq zmin z)) (when (or (null zmax) (> z zmax)) (setq zmax z)))) vertices) (list (make-point xmin ymin zmin) (make-point xmax ymax zmax))))) (%native-brep% (let ((brep (make-brep *geometry-kernel* :tolerance (the brep-tolerance)))) (let ((x-vector (the (face-normal-vector :right))) (y-vector (the (face-normal-vector :rear))) (corner (the (vertex :left :front :bottom)))) (let ((origin-x (get-x corner)) (origin-y (get-y corner)) (origin-z (get-z corner))) (add-box-primitive *geometry-kernel* brep (the width)(the length)(the height) origin-x origin-y origin-z (get-x x-vector) (get-y x-vector) (get-z x-vector) (get-x y-vector) (get-y y-vector) (get-z y-vector))) (unless (the brep-tolerance) (brep-reset-tolerance *geometry-kernel* brep)) brep))))) ;; (define-object test-box-solid (box-solid) ;; :computed-slots ((length 10) (width 20) (height 30)))
4,010
Common Lisp
.lisp
67
42.298507
150
0.542391
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7d8d40e33c5e50831ce123f3da3761cb14a1a814d4bcc8bb52cfa966ffc2cbda
35,834
[ -1 ]
35,835
planar-contour-surface.lisp
lisp-mirror_gendl/surf/source/planar-contour-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object planar-contour-surface (trimmed-surface) :input-slots (island-curve (plane-normal nil)) :computed-slots ((island (the island-curve)) (island-curve-boundary (the island bounding-box))) :hidden-objects ( (basis-surface :type 'rectangular-surface :center (apply #'midpoint (the island-curve bounding-box)) :width (apply #'3d-distance (the island-curve bounding-box)) :length (apply #'3d-distance (the island-curve bounding-box)) :orientation (alignment :top (or (the plane-normal) (cross-vectors (the island-curve (tangent (the island-curve u-min))) (the island-curve (normal (the island-curve u-min))))))))) (define-object test-planar-contour-surface (planar-contour-surface) :hidden-objects ( (island-curve :type 'b-spline-curve :control-points (list (make-point 3 5 1) (make-point 5 8.0 1) (make-point 7 10.0 1) (make-point 8 5.0 1) (make-point 7 0.0 1) (make-point 5 0.0 1) (make-point 3 5 1)))))
2,426
Common Lisp
.lisp
51
33.666667
96
0.555603
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3a15cd11e7a1f5ff09262a677f2462a57c4ad384925c8c5c5efbffc7ddb964a5
35,835
[ -1 ]
35,836
rectangular-surface.lisp
lisp-mirror_gendl/surf/source/rectangular-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object rectangular-surface (planar-surface) :documentation (:description "Creates a flat rectangular surface specified by the same inputs as box or base-object." :examples "<pre> (in-package :surf) (define-object test-rectangular-surface (rectangular-surface) :computed-slots ((display-controls (list :color :green-spring-medium)) (length 20) (width 30) (height 0))) (generate-sample-drawing :objects (make-object 'test-rectangular-surface) :projection-direction :trimetric) </pre>") :input-slots ((center (make-point 0 0 0) :defaulting) length width height) :computed-slots ((p00 (translate (the center) :left (half (the width)) :front (half (the length)))) (p01 (translate (the center) :left (half (the width)) :rear (half (the length)))) (p10 (translate (the center) :right (half (the width)) :front (half (the length)))) (p11 (translate (the center) :right (half (the width)) :rear (half (the length)))))) (define-object test-rectangular-surface (rectangular-surface) :computed-slots ((length 20) (width 30) (height 0)) :hidden-objects ((view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :width (* 5 72) :length (* 5 72) :objects (list self))))
2,308
Common Lisp
.lisp
45
44.288889
120
0.676152
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
3848f4e00e4fb4451341ee8ed3b668fe41cb4ffe73b91d90fab3b614a889da66
35,836
[ -1 ]
35,837
merged-brep.lisp
lisp-mirror_gendl/surf/source/merged-brep.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object boolean-tree (brep) :input-slots (breps (operation :merge)) :computed-slots ( (%native-brep% (merge-breps *geometry-kernel* :breps (the breps) :operation (the operation))))) (define-object merged-brep (brep) :input-slots (breps (sew-tolerances (the sew-tolerances-default))) :computed-slots ( (sew-tolerances-default (let ((brep-tolerances (mapsend (the breps) :adaptive-tolerance))) (list (apply #'min brep-tolerances) (apply #'max brep-tolerances)))) (%native-brep% (let ((new-brep (brep-copy *geometry-kernel* (first (the breps))))) (dolist (brep (rest (the breps)) (if (the sew-tolerances) (sew-brep *geometry-kernel* :brep new-brep :tolerances (the sew-tolerances)) new-brep)) (merge-brep *geometry-kernel* :brep new-brep :brep-to-merge (the-object brep %native-brep%)))))))
2,483
Common Lisp
.lisp
44
36.5
103
0.530935
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7f4a99fe0c85a9c6ce7dc66605f0f962f492e202b2a43d8ae0ebf136a460fa40
35,837
[ -1 ]
35,838
general-sweep.lisp
lisp-mirror_gendl/surf/source/general-sweep.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object general-sweep (b-spline-surface) :input-slots (guide-curve profile-curve v1-function v2-function (nsegments (1- (length (the guide-curve control-points)))) (untwist? nil) (v-degree 3) (end-caps-on-brep? nil) ) :computed-slots ( (control-points (mapcar #'(lambda(profile) (the-object profile control-points)) (cons (the start-profile) (list-elements (the rest-profiles rest-profiles))))) (weights (mapcar #'(lambda(profile) (the-object profile weights)) (cons (the start-profile) (list-elements (the rest-profiles rest-profiles))))) ;;(u-knot-vector (the profile-curve knot-vector)) (v-knot-vector (the guide-curve knot-vector)) ;;(u-degree (the profile-curve degree)) (u-degree 1) (guide-control-grid-length (apply #'+ (the guide-control-distances))) (guide-control-distances (mapcar #'3d-distance (the guide-curve control-points) (rest (the guide-curve control-points)))) (guide-control-cumulative-distances (let ((total 0)) (mapcar #'(lambda(length) (setq total (+ total length))) (the guide-control-distances)))) (guide-curve-params (make-array (length (the guide-control-cumulative-distances)) :initial-contents (mapcar #'(lambda(cumulative-length) (* (/ cumulative-length (the guide-control-grid-length)) (the guide-param-extent))) (the guide-control-cumulative-distances)))) (guide-param-extent (- (the guide-curve u-max) (the guide-curve u-min))) (guide-curve-stations (make-array (length (the guide-curve-params)) :initial-contents (mapcar #'(lambda(param) (the guide-curve (point param))) (coerce (the guide-curve-params) 'list))) ;; ;; FLAG -- why doesn't it work this way? ;; #+nil (map 'array #'(lambda(param) (the guide-curve (point param))) (the guide-curve-params)))) :objects ( ;; ;; FLAG -- investigate using guide curve as spine ;; (lofted :type 'lofted-surface :synchronized? t :end-caps-on-brep? (the end-caps-on-brep?) :curves (cons (the start-profile) (list-elements (the rest-profiles rest-profiles)))) (start-profile :type 'boxed-curve :curve-in (the profile-curve) :center (the guide-curve start) :orientation (alignment :right (funcall (the v1-function) (the guide-curve u1)) :top (funcall (the v2-function) (the guide-curve u1)))) (rest-profiles :type 'profile-set :curve-in (the start-profile) :guide-curve-control-points (the guide-curve control-points) :pass-down (guide-curve-params guide-curve-stations v1-function v2-function)))) (define-object normal-sweep (general-sweep) :computed-slots ((v2-function #'(lambda(param) (the guide-curve (tangent param)) )) (v1-function #'(lambda(param) (declare (ignore param)) (the (face-normal-vector :bottom)))))) (define-object profile-set (base-object) :input-slots (curve-in guide-curve-params guide-curve-stations v1-function v2-function guide-curve-control-points) :objects ((rest-profiles :type 'boxed-curve :curve-in (the curve-in) :sequence (:size (length (the guide-curve-params))) :center (aref (the guide-curve-stations) (the-child index)) :orientation (let ((param (aref (the guide-curve-params) (the-child index)))) (alignment :right (funcall (the v1-function) param) :top (funcall (the v2-function) param) ))))) #+nil (define-object test-g-s (general-sweep) :computed-slots ( ;;(display-controls (list :isos (list :n-u 80 :n-v 20))) (profile-curve (the test-data-set expected-surf-data1 (input-entities 1))) (guide-curve (the test-data-set expected-surf-data1 (input-entities 0))) (v1-function #'(lambda(param) (the guide-curve (tangent param)) )) (v2-function #'(lambda(param) (cross-vectors (the (face-normal-vector :right)) (the guide-curve (tangent param))))) (expected-result (the test-data-set expected-surf-data1 entity)) ) :objects ((test-data-set :type 'test-guide-normal-on-surface-sweep) (profile-view :type 'curve :built-from (the profile-curve)) (guide-view :type 'curve :built-from (the guide-curve)) (guide-points :type 'points-display :points (the guide-curve control-points)) (dropped :type 'dropped-curve :curve-in (the guide-curve) :surface (the test-data-set expected-surf-data1 (input-entities 2))) ))
7,900
Common Lisp
.lisp
155
30.490323
95
0.50056
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5a52ad57a2368b0a2a2fb91bd45134161f53df77e3ab8f316f7f9539ea35628b
35,838
[ -1 ]
35,839
planar-offset-curve.lisp
lisp-mirror_gendl/surf/source/planar-offset-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object planar-offset-curve (curve) :documentation (:description "Creates a curve which is the result of offsetting a curve by its normals along a plane." :examples "<pre> (in-package :surf) (define-object test-planar-offset-curve () :computed-slots ((curve-in (the b-spline-curves (curves 3))) (plane-normal (make-vector 0 0 -1)) (distance 1) ) :objects ((b-spline-curves :type 'test-b-spline-curves :hidden? t) (curve-to-be-offset :type 'curve :built-from (the b-spline-curves (curves 3))) (planar-offset-curve :type 'surf:planar-offset-curve :curve-in (the curve-to-be-offset) :plane-normal (make-vector 0 0 -1) :distance 1))) (generate-sample-drawing :object-roots (list (make-object 'test-planar-offset-curve)) :projection-direction (getf *standard-views* :top)) </pre>") :input-slots ("GDL Curve. The curve to be offset" curve-in "3D Vector. The normal for the plane" plane-normal "Number. The left-hand distance to offset with respect to curve direction. To get the opposite direction, you can either negate this number or reverse the <tt>plane-normal</tt>." distance ("Number. The tolerance for approximating the resulting offset curve. Defaults to *3d-approximation-tolerance-default*." tolerance *3d-approximation-tolerance-default*)) :computed-slots ((native-curve-iw (make-offset-curve *geometry-kernel* :curve (the curve-in) :plane-normal (the plane-normal) :offset-distance (- (the distance)) :tolerance (the tolerance))))) (define-object test-planar-offset-curve () :computed-slots ((curve-in (the b-spline-curves (curves 3))) (plane-normal (make-vector 0 0 -1)) (distance 1) (tolerance 0.001) ) :objects ((b-spline-curves :type 'test-b-spline-curves :hidden? t) (curve-to-be-offset :type 'curve :built-from (the b-spline-curves (curves 3))) (planar-offset-curve :type 'surf:planar-offset-curve :curve-in (the curve-to-be-offset) :plane-normal (make-vector 0 0 -1) :tolerance (the tolerance) :distance 1)))
3,523
Common Lisp
.lisp
73
37.136986
121
0.621581
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8c02501a638c89ab04f700e5f49002baedba63ecc21fefb3203bce4dd17c0753
35,839
[ -1 ]
35,840
b-spline-curve.lisp
lisp-mirror_gendl/surf/source/b-spline-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (eval-when (:compile-toplevel :load-toplevel :execute) (define-object b-spline-curve (curve) :documentation (:description "A general NURBS (potentially non-Uniform, potentially Rational, b-spline) curve specified with control points, weights, knots, and degree. If the knot-vector is different from the default, it is non-Uniform. If any of the weights are different from 1.0, it is Rational." :examples "<pre> (in-package :surf) (define-object test-b-spline-curves (base-object) :input-slots ((control-points (list (make-point 0 0 0) (make-point 2 3.0 0.0) (make-point 4 2.0 0.0) (make-point 5 0.0 0.0) (make-point 4 -2.0 0.0) (make-point 2 -3.0 0.0) (make-point 0 0 0)))) :objects ((curves :type 'b-spline-curve :sequence (:size 6) :control-points (the control-points) :degree (1+ (the-child :index)) :display-controls (list :line-thickness (* 0.3 (the-child index)) :color (ecase (the-child index) (0 :red) (1 :orange) (2 :yellow) (3 :green) (4 :blue) (5 :red-violet)))) (points :type 'point :sequence (:size (length (rest (the control-points)))) :center (nth (the-child index) (rest (the control-points))) :display-controls (list :color :green)))) (generate-sample-drawing :object-roots (make-object 'test-b-spline-curves)) ;; Here is another example which shows the difference between a ;; simple bezier-curve from the :geom-base package, and a NURBS. ;; (define-object bezier-and-nurbs (base-object) :input-slots ((control-points (list (make-point 0 0 0) (make-point 1 1 0) (make-point 2 1 0) (make-point 3 0 0)))) :objects ((points :type 'points-display :points (the control-points)) (bezier :type 'bezier-curve ;; This will be a geom-base:bezier-curve :display-controls (list :color :green) :control-points (the control-points)) (b-spline :type 'b-spline-curve ;; This will be an equivalent surf:b-spline-curve. :display-controls (list :color :red :bezier-points t) :control-points (the bezier control-points)) ;; ;; The b-spline-curve is a full NURBS curve and so has ;; more inputs than a simple bezier-curve: degree, ;; weights, and knot-vector, so we can do things like: ;; (b-spline-weighted :type 'b-spline-curve :display-controls (list :color :purple) :control-points (the bezier control-points) :weights (list 1.0 1.2 1.2 1.0)) (b-spline-degree-2 :type 'b-spline-curve :display-controls (list :color :orange) :control-points (the bezier control-points) :degree 2))) </pre>") :input-slots ("List of 3D Points. The control points." control-points ("Integer. Degree of the curve. Defaults to 3 (cubic)." degree 3) ("List of Numbers. Knots of the curve. Default is NIL, which indicates a uniform knot vector." knot-vector (make-uniform-knot-vector (length (the control-points)) (the degree))) ("List of numbers. A weight to match each control point. Should be same length as control-points. Default is a value of 1.0 for each weight, resulting in a nonrational curve." weights (make-list (length (the control-points)) :initial-element 1.0)) ("Boolean. Indicates whether the inputted control-points should be considered in local coordinate system of this object. Default is nil." local? nil) (surface nil) ) :computed-slots ((native-curve (make-b-spline-curve *geometry-kernel* (if (the local?) (mapcar #'(lambda(point) (the (local-to-global point))) (the control-points)) (the control-points)) (mapcar #'to-double-float (the weights)) (the degree) (the knot-vector))) (%renderer-info% (list :vrml? t :view-default :top)) ))) (define-object test-b-spline-curves (base-object) :input-slots ((control-points (list (make-point 0 0 0) (make-point 2 3.0 0.0) (make-point 4 2.0 0.0) (make-point 5 0.0 0.0) (make-point 4 -2.0 0.0) (make-point 2 -3.0 0.0) (make-point 0 0 0)))) :hidden-objects ((view :type 'base-view :page-length (* 5 72) :page-width (* 5 72) :pseudo-inputs (page-length page-width) :objects (the children))) :objects ((note :type 'general-note :strings "Hey Now") (curves :type 'b-spline-curve :sequence (:size 6) :control-points (the control-points) :degree (1+ (the-child :index)) :display-controls (list :line-thickness 3 ;;(* 0.3 (the-child index)) :dash-pattern (list 10 10) :fill-color (ecase (the-child index) (0 :red) (1 :orange) (2 :yellow) (3 :green) (4 :blue) (5 :red-violet)) :color (ecase (the-child index) (0 :red) (1 :orange) (2 :yellow) (3 :green) (4 :blue) (5 :red-violet)))) (points :type 'point :sequence (:size (length (rest (the control-points)))) :center (nth (the-child index) (rest (the control-points))) :display-controls (list :color :green))))
7,542
Common Lisp
.lisp
141
36.929078
144
0.536374
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
21bb549a9527b195135f5417597fa1d03545286671c6be2d48e7c9c7d56993e3
35,840
[ -1 ]
35,841
tests.lisp
lisp-mirror_gendl/surf/source/tests.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; #| (in-package :gdl-user) (define-object test-planar-section-curve (planar-section-curve) :input-slots (( )) :objects ((loft :type 'test-lofted-surface) (planar-section :type 'planar-section-curve :surface (the loft) :plane-vector (the (face-normal-vector :right)) :plane-point (the center) ))) (define-object test-lofted-surface (lofted-surface) :input-slots ((width 50) (length 10) (display-controls (list :color :blue :transparency 0.5))) :computed-slots ((curves (list (the curve-1) (the curve-2) (the curve-3)))) :hidden-objects ((curve-1 :type 'linear-curve :start (translate (the center) :left (half (the width)) :rear (half (the length))) :end (translate (the-child start) :front (the length))) (curve-2 :type 'linear-curve :start (translate (the center) :rear (half (the length)) :up (half (the length))) :end (translate (the center) :front (half (the length)))) (curve-3 :type 'linear-curve :start (translate (the center) :right (half (the width)) :rear (half (the length))) :end (translate (the-child start) :front (the length))))) (define-object test-trimmed-surface (trimmed-surface) :input-slots ((width 110) (length 110) (inset 10)) :computed-slots ( (curve-length (- (the length) (the inset))) (curve-width (- (the width) (the inset))) (island (the composed))) :objects ((top-curve :type 'linear-curve :start (translate (the center) :rear (half (the curve-length)) :right (half (the curve-width))) :end (translate (the-child start) :left (the curve-width))) (left-curve :type 'linear-curve :start (the top-curve end) :end (translate (the-child start) :front (the curve-length))) (bottom-curve-1 :type 'linear-curve :start (the left-curve end) :end (translate (the-child start) :right (half (the curve-width)))) (bottom-curve-2 :type 'linear-curve :start (the bottom-curve-1 end) :end (translate (the-child start) :right (half (the curve-width)))) (bottom-curve :type 'linear-curve :start (the left-curve end) :end (translate (the-child start) :right (the curve-width))) (right-curve :type 'linear-curve :start (the bottom-curve-2 end) :end (the top-curve start)) (composed :type 'composed-curve :curves (list (the top-curve) (the left-curve) ;;(the bottom-curve-1) ;;(the bottom-curve-2) (the bottom-curve) (the right-curve))) (decomposed :type 'decomposed-curves :curve-in (the composed)) (projected-curve :type 'projected-curve :curve-in (the composed) :surface (the basis-surface) :projection-vector (the (face-normal-vector :top))) (basis-surface :type 'rectangular-surface))) |#
4,436
Common Lisp
.lisp
97
33.391753
96
0.577478
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4251cc464446b16a73dc2520cd3511e54018eadbe6bf1290b7edb9695bbc4c4c
35,841
[ -1 ]
35,842
subdivided-curve.lisp
lisp-mirror_gendl/surf/source/subdivided-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object subdivided-curve (curve) :input-slots (curve-in (continuity-type :discontinuous) (continuity-angle 0)) :computed-slots ((available-continuity-types (list :discontinuous :c0 :g1 :g1r :g1_g2 :c1 :c1_g2 :c1_c2 :cinfinity)) (native-curves (curve-subdivide-at-discontinuities *geometry-kernel* :curve (the curve-in) :continuity-type (1+ (position (the continuity-type) (the available-continuity-types))) :continuity-angle (the continuity-angle)))) :objects ((curves :type 'curve :sequence (:size (length (the native-curves))) :native-curve-iw (nth (the-child index) (the native-curves)))))
1,974
Common Lisp
.lisp
41
34.487805
103
0.571053
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8af471862b15b549c7fe050cd932f7bb92648f846a45e47c3b19e45ef0e41a59
35,842
[ -1 ]
35,843
silhouette-curves.lisp
lisp-mirror_gendl/surf/source/silhouette-curves.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object silhouette-curves (base-object) ;; ;; FLAG -- detect if surface is a face and take its basis surface. ;; :input-slots (surface (eye-point-or-vector (the (face-normal-vector :top))) (perspective? nil) (tolerance (the surface brep adaptive-tolerance)) (angle-tolerance-radians *angle-tolerance-radians-default*)) :computed-slots ((curves-and-uv-curves (multiple-value-list (surface-create-silhouette-curves *geometry-kernel* :surface (if (typep (the surface) 'face) (the surface basis-surface) (the surface)) :eye-point-or-vector (the eye-point-or-vector) :perspective? (the perspective?) :tolerance (the tolerance) :angle-tolerance (the angle-tolerance-radians)))) (relevant-curves (remove-if #'(lambda(curve) (or (same-direction-vectors? (subtract-vectors (the-object curve end) (the-object curve start)) (the eye-point-or-vector)) (same-direction-vectors? (subtract-vectors (the-object curve end) (the-object curve start)) (reverse-vector (the eye-point-or-vector))))) (list-elements (the all-curves)))) (trimmed-curves-native (when (typep (the surface) 'face) (make-trimmed-iso-curves *geometry-kernel* (the surface %native-face%) *display-tolerance* (mapcar #'(lambda(curve) (the-object curve native-curve-iw)) (list-elements (the curves))) nil)))) :hidden-objects ((all-curves :type 'curve :sequence (:size (length (first (the curves-and-uv-curves)))) :native-curve-iw (nth (the-child index) (first (the curves-and-uv-curves))))) :objects ((curves :type 'curve :hidden? (typep (the surface) 'face) :sequence (:size (length (the relevant-curves))) :built-from (nth (the-child index) (the relevant-curves))) (uv-curves :type 'curve :hidden? (typep (the surface) 'face) :sequence (:size (length (second (the curves-and-uv-curves)))) :native-curve-iw (nth (the-child index) (second (the curves-and-uv-curves)))) (trimmed-curves :type 'curve :hidden? (not (typep (the surface) 'face)) :sequence (:size (length (the trimmed-curves-native))) :native-curve-iw (nth (the-child index) (the trimmed-curves-native))) ;; ;; FLAG -- pass UV curves into this. ;; )) (define-object silhouettes-group () :input-slots (iges-reader eye-point-or-vector) :objects ((silhouettes :type 'silhouette-curves :sequence (:size (the iges-reader breps number-of-elements)) :surface (the iges-reader (breps (the-child index)) (faces 0)) :pass-down (eye-point-or-vector)) (composed :type 'composed-curves :curves-in (list-elements (the trimmed-curves))))) (define-object cat-scan-section (planar-section-curves) :input-slots (plane-base) :computed-slots ((built-from (the (curves 0))) (min-x (least #'get-x (mapcar #'(lambda(curve) (getf (the-object curve min-max-x-y-z) :min-x)) (list-elements (the curves))))) (max-x (most #'get-x (mapcar #'(lambda(curve) (getf (the-object curve min-max-x-y-z) :max-x)) (list-elements (the curves)))))))
5,171
Common Lisp
.lisp
108
33.092593
92
0.544198
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
015791fc29e6614dd5c3cc63908f6718ee9a1825ae4b1d5ac4e42bda71dab7e3
35,843
[ -1 ]
35,844
surface.lisp
lisp-mirror_gendl/surf/source/surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (defun pin-value-to-range (value min max &key (lt-test #'<) (gt-test #'>)) #+nil "Number. Returns a value pinned to the range described by the min and max. If the input value is out of range, a warning is issued. :args (value \"Input value\" min \"minimum end of allowed range\" max \"maximum end of allowed range\") :&key ((lt-test #'<) \"The test applied for less-than comparison\" (gt-test #'>) \"The test applied for greater-than comparison\") " (cond ((funcall lt-test value min) (warn "Value ~a is less than minimum allowed ~a, pinning to ~a.~%" value min min) min) ((funcall gt-test value max) (warn "Value ~a is greater than maximum allowed ~a, pinning to ~a.~%" value max max) max) (t value))) ;; ;; FLAG - move into gdl-base module. ;; (defmacro with-pinned-values ((&rest bindings) &body body) "Macro. Takes a list of bindings and body similar to let, but each binding contains a variable, which must already exist in this context, followed by a min and a max value to which its inner binding will be pinned. If the value of the outer binding falls outside the range, a warning will be issued." `(let (,@(mapcar #'(lambda(binding) `(,(first binding) (pin-value-to-range ,(first binding) ,(second binding) ,(third binding)))) bindings)) ,@body)) (define-object surface (geometry-kernel-object-mixin outline-specialization-mixin base-object) :documentation (:description "A generalized NURBS surface. Usually used as a mixin in more specific surfaces.") :input-slots (("GDL Surface. Specify this if you want this surface to be a clone of an existing surface (note - this uses a shared underlying surface object, it does not make a copy)" built-from nil) (%schedule-finalization?% t) (native-surface (get-nurbs-from-surface *geometry-kernel* (the native-surface-iw))) (native-pointer nil) (native-surface-iw (or (the native-pointer) (cond ((the built-from) (the built-from native-surface-iw)) ((null (the native-surface)) (error "No native-surface instantiated")) (t (make-b-spline-surface* *geometry-kernel* (the native-surface) :schedule-finalization? (the %schedule-finalization?%)))))) ("Number. Approximation tolerance for display purposes." tolerance *display-tolerance*) ("Number. Overall tolerance for the internal brep representation of this surface. Defaults to nil. Note that a value of nil indicates for SMLib a value of 1.0e-05 of the longest diagonal length of the brep." brep-tolerance nil) (parameterization 4) (nonrational-degree 3) ("Plist with keys :n-u and :n-v. The number of isoparametric curves to be displayed in each direction. This value comes from the value of :isos on the display-controls if that exists, and defaults to *isos-default* otherwise." isos (getf (the display-controls) :isos *isos-default*) :defaulting) ("Boolean. Indicates whether to attempt automatic endcaps on conversion of this surface to a brep. Note that this might change in future to a keyword value for :min, :max, or :both to provide more control." end-caps-on-brep? nil) ("Boolean. Indicates whether brep representation should undergo a sew-and-orient operation. Defaults to nil." sew-and-orient-brep? nil) ("Plist of keyword symbols and numbers. This controls tessellation for the brep of this surface. The keys are as follows: <ul> <li><tt>:min-number-of-segments</tt></li> <li><tt>:max-3d-edge-factor</tt></li> <li><tt>:min-parametric-ratio</tt></li> <li><tt>:max-chord-height</tt></li> <li><tt>:max-angle-degrees</tt></li> <li><tt>:min-3d-edge</tt></li> <li><tt>:min-edge-ratio-uv</tt></li> <li><tt>:max-aspect-ratio</tt></li> </ul> and the defaults come from the following parameters: <pre> (list :min-number-of-segments *tess-min-number-of-segments* :max-3d-edge-factor *tess-max-3d-edge-factor* :min-parametric-ratio *tess-min-parametric-ratio* :max-chord-height *tess-max-chord-height* :max-angle-degrees *tess-max-angle-degrees* :min-3d-edge *tess-min-3d-edge* :min-edge-ratio-uv *tess-min-edge-ratio-uv* :max-aspect-ratio *tess-max-aspect-ratio*) </pre> " tessellation-parameters (list :min-number-of-segments *tess-min-number-of-segments* :max-3d-edge-factor *tess-max-3d-edge-factor* :min-parametric-ratio *tess-min-parametric-ratio* :max-chord-height *tess-max-chord-height* :max-angle-degrees *tess-max-angle-degrees* :min-3d-edge *tess-min-3d-edge* :min-edge-ratio-uv *tess-min-edge-ratio-uv* :max-aspect-ratio *tess-max-aspect-ratio*)) ("Boolean. Returns non-nil iff this surface is rational, i.e. all weights are not 1." rational? (not (every #'(lambda(weight) (near-to? weight 1.0)) (apply #'append (the weights)))))) :computed-slots ( ;; ;; FLAG -- make sure this doesn't step on b-spline-surface inputs ;; (b-spline-data-list (multiple-value-list (the b-spline-data))) (control-points (first (the b-spline-data-list))) (weights (second (the b-spline-data-list))) (u-knot-vector (third (the b-spline-data-list))) (v-knot-vector (fourth (the b-spline-data-list))) (u-degree (fifth (the b-spline-data-list))) (v-degree (sixth (the b-spline-data-list))) ;; ;; (basis-surface self) (iso-curves (list :u (get-iso-curves *geometry-kernel* self :u (getf (the isos) :n-u)) :v (get-iso-curves *geometry-kernel* self :v (or (getf (the isos) :n-v))))) ;; ;; FLAG -- replace with bounding box directly from kernel. ;; (bounding-box (bounding-box-from-points (flatten (the control-points)) #+nil (apply #'append (apply #'append (mapsend (the outline-objects) :%curves-to-draw%))))) (control-points-local (mapcar #'(lambda(list) (mapcar #'(lambda(point) (the (global-to-local point))) list)) (the b-spline-data))) (width (the bounding-bbox width)) (height (the bounding-bbox height)) (length (the bounding-bbox length)) (%renderer-info% (list :vrml? t :view-default :trimetric)) (%control-points% (the b-spline-data)) (%control-points-transposed% (apply #'mapcar #'list (the b-spline-data))) (outline-objects (append (when (or (eql (getf (the display-controls) :isos :no) :no) (getf (getf (the display-controls) :isos) :n-u)) (list-elements (the u-iso-curves))) (when (or (eql (getf (the display-controls) :isos :no) :no) (getf (getf (the display-controls) :isos) :n-v)) (list-elements (the v-iso-curves))) (when (getf (the display-controls) :bezier-points) (append (list-elements (the control-grid)))))) (min-max-x-y-z (the %min-max-x-y-z%))) :hidden-objects ((control-grid :type 'points-display :sequence (:size (length (the %control-points%))) :points (nth (the-child index)(the %control-points%))) (control-grid-u :type 'global-polyline :sequence (:size (length (the %control-points%))) :vertex-list (the (control-grid (the-child index)) points)) (control-grid-v :type 'global-polyline :sequence (:size (length (the %control-points-transposed%))) :vertex-list (nth (the-child index) (the %control-points-transposed%))) ("Sequence of curve objects. The isoparametric curves in the U direction." u-iso-curves :type 'curve :sequence (:size (length (getf (the iso-curves) :u))) :curve-list (getf (the iso-curves) :u) :pseudo-inputs (curve-list) :native-curve (nth (the-child index) (the-child curve-list))) ("Sequence of curve objects. The isoparametric curves in the V direction." v-iso-curves :type 'curve :sequence (:size (length (getf (the iso-curves) :v))) :curve-list (getf (the iso-curves) :v) :pseudo-inputs (curve-list) :native-curve (nth (the-child index) (the-child curve-list))) (test-copy :type 'b-spline-surface :parameters (multiple-value-bind (control-points weights u-knots v-knots u-degree v-degree) (the b-spline-data) (list :control-points control-points :weights weights :u-knot-vector u-knots :v-knot-vector v-knots :u-degree u-degree :v-degree v-degree))) ("GDL Brep object. This is the brep representation of this surface." brep :type 'brep-from-surface :surface (multiple-value-bind (control-points weights u-knots v-knots u-degree v-degree) (the b-spline-data) (make-object 'b-spline-surface :control-points control-points :weights weights :u-knot-vector u-knots :v-knot-vector v-knots :u-degree u-degree :v-degree v-degree :%schedule-finalization?% t)) :tessellation-parameters (the tessellation-parameters) :pass-down (brep-tolerance sew-and-orient-brep?) :end-caps? (the end-caps-on-brep?)) ("GDL surface object. This surface object swaps the role of u and v- directional parameters, i.e. old-surface(u,v) = new-surface(v,u)." swapped-uv-surface :type 'surface :native-surface (let ((copy (the fresh-copy))) (funcall (read-from-string "smlib::surface-swap-uv") (the-object copy native-surface))))) :functions ((%min-max-x-y-z% (&optional (tolerance *zero-epsilon*)) (flet ((min-max (accessor comparison) (let (current-u) (let ((v (min-max-search #'(lambda(v-param) (let ((u-param (min-max-search #'(lambda(u-param) (funcall accessor (the (point u-param v-param)))) comparison (the u-min) (the u-max) tolerance))) (setq current-u u-param) (funcall accessor (the (point u-param v-param))))) comparison (the v-min) (the v-max) tolerance))) (list current-u v))))) (let ((min-x (min-max #'get-x #'<)) (max-x (min-max #'get-x #'>)) (min-y (min-max #'get-y #'<)) (max-y (min-max #'get-y #'>)) (min-z (min-max #'get-z #'<)) (max-z (min-max #'get-z #'>))) (list :min-x (the (point (first min-x) (second min-x))) :min-x-params min-x :max-x (the (point (first max-x) (second max-x))) :max-x-params max-x :min-y (the (point (first min-y) (second min-y))) :min-y-params min-y :max-y (the (point (first max-y) (second max-y))) :max-y-params max-y :min-z (the (point (first min-z) (second min-z))) :min-z-params min-z :max-z (the (point (first max-z) (second max-z))) :max-z-params max-z)))) (fresh-copy () (multiple-value-bind (control-points weights u-knots v-knots u-degree v-degree) (the b-spline-data) (make-object 'b-spline-surface :control-points control-points :weights weights :u-knot-vector u-knots :v-knot-vector v-knots :u-degree u-degree :v-degree v-degree))) (write-stl-file (file-name &key (format :ascii)) (the brep (write-stl-file file-name :format format))) ("Number. Returns the area of the surface. :&key ((desired-accuracy 0.000001) \"Number. Desired accuracy of result. Should not be smaller than 0.00000001 (10e-08).\")" area (&key (desired-accuracy 0.000001)) (surface-area *geometry-kernel* (the native-surface-iw) desired-accuracy)) #+allegro ("List of Surface points. Returns the given 3D point dropped normally to this surface. :arguments (point \"3D Point. The point to be dropped.\") :&key ((3d-tolerance *3d-tolerance-default*) \"The tolerance used for dropping.\")" dropped-points (point &key (3d-tolerance *3d-tolerance-default*)) (let ((uv-pairs (surface-drop-point *geometry-kernel* self point :3d-tolerance 3d-tolerance))) (mapcar #'(lambda(uv-pair) (make-surface-point :uv-point (make-point (first uv-pair) (second uv-pair)) :3d-point (the (point (first uv-pair) (second uv-pair))))) uv-pairs))) ("Returns a bbox object, answering xmin, ymin, zmin, xmax, ymax, and zmax, for a box containing the convex hull (i.e. the control points) of this surface and oriented according to the given <tt>center</tt> and <tt>orientation</tt>." local-bounding-box (center orientation) (let* ((object (make-object 'base-object :center center :orientation orientation)) (points (mapcar #'(lambda(point) (the-object object (global-to-local point))) (apply #'append (the b-spline-data))))) (let ((xmax (apply #'max (mapcar #'get-x points))) (ymax (apply #'max (mapcar #'get-y points))) (zmax (apply #'max (mapcar #'get-z points))) (xmin (apply #'min (mapcar #'get-x points))) (ymin (apply #'min (mapcar #'get-y points))) (zmin (apply #'min (mapcar #'get-z points)))) (make-object 'bbox :xmax xmax :ymax ymax :zmax zmax :xmin xmin :ymin ymin :zmin zmin)))) #+allegro ("Surface point. Returns the given 3D point dropped normally to this surface, as close as possible to the given 3D point. :arguments (point \"3D Point. The point to be dropped.\") :&key ((3d-tolerance *3d-tolerance-default*) \"The tolerance used for dropping.\")" dropped-point (point &key (3d-tolerance *3d-tolerance-default*)) (let ((uv-pairs (surface-drop-point *geometry-kernel* self point :3d-tolerance 3d-tolerance))) (first (sort (mapcar #'(lambda(uv-pair) (make-surface-point :uv-point (make-point (first uv-pair) (second uv-pair)) :3d-point (the (point (first uv-pair) (second uv-pair))))) uv-pairs) #'(lambda(p1 p2) (< (3d-distance (get-3d-point-of p1) point) (3d-distance (get-3d-point-of p2) point))))))) ("Plist. The returned plist contains information about the minimum distance from this surface to the curve given as the argument. :arguments (curve \"GDL Curve object\")" minimum-distance-to-curve (curve) (the (curve-solve curve :minimize))) #+allegro ("Plist. The returned plist contains information about the maximum distance from this surface to the curve given as the argument. :arguments (curve \"GDL Curve object\")" maximum-distance-to-curve (curve) (the (curve-solve curve :maximize))) (curve-solve (curve operation) (let ((result (first (global-surface-curve-solve *geometry-kernel* self :curve curve :operation-type operation)))) (when result (destructuring-bind (parameter surface-u surface-v) result (let ((point-on-curve (when parameter (make-surface-point :parameter parameter :3d-point (the-object curve (point parameter))))) (point-on-surface (when (and surface-u surface-v) (make-surface-point :uv-point (make-point surface-u surface-v) :3d-point (the (point surface-u surface-v)))))) (let ((distance (when (and point-on-curve point-on-surface) (3d-distance (get-3d-point-of point-on-curve) (get-3d-point-of point-on-surface))))) (list :point-on-curve point-on-curve :point-on-surface point-on-surface :distance distance))))))) ("Plist. The returned plist contains information about the minimum distance from this surface to the surface given as the argument. :arguments (surface \"GDL Surface object\")" minimum-distance-to-surface (surface) (the (surface-solve surface :minimize))) #+allegro ("Plist. The returned plist contains information about the maximum distance from this surface to the surface given as the argument. :arguments (surface \"GDL Surface object\")" maximum-distance-to-surface (surface) (the (surface-solve surface :maximize))) (surface-solve (surface operation) (destructuring-bind (surface-u surface-v other-surface-u other-surface-v) (first (global-surface-surface-solve *geometry-kernel* self :other-surface surface :operation-type operation)) (let ((point-on-surface (when (and surface-u surface-v) (make-surface-point :uv-point (make-point surface-u surface-v) :3d-point (the (point surface-u surface-v))))) (point-on-other-surface (when (and other-surface-u other-surface-v) (make-surface-point :uv-point (make-point other-surface-u other-surface-v) :3d-point (the-object surface (point other-surface-u other-surface-v)))))) (let ((distance (when (and point-on-surface point-on-other-surface) (3d-distance (get-3d-point-of point-on-surface) (get-3d-point-of point-on-other-surface))))) (list :point-on-surface point-on-surface :point-on-other-surface point-on-other-surface :distance distance))))) ("3D Point. Returns the surface point at the given parameters offset along the surface normal at that point by the given distance. :arguments (u \"Number. The U parameter for the surface point.\" v \"Number. The V parameter for the surface point.\" distance \"Number. The distance for offsetting.\")" offset-point (u v distance) (let ((point (the (point u v))) (normal (the (normal u v)))) (translate-along-vector point normal distance))) ("Number. Returns the Gaussian curvature on the surface at the given parameter values. Three additional values are returned, which are the Normal Curvature at the point, the first Fundamental Principle Curvature, and the second Fundamental Principle Curvature. :note This function might be updated to provide a clearer idea of actual radius of curvature; at the time of this writing it is not clear what the relationship is between the four returned values and actual radius of curvature. :arguments (u \"Number. The U parameter for the surface point.\" v \"Number. The V parameter for the surface point.\")" radius-of-curvature (u v) (surface-evaluate-geometric *geometry-kernel* self u v)) ("List of Surface points. Returns the given point projected along the given vector intersected with the surface. :arguments (point \"3D Point. The point to be projected.\" vector \"3D Vector. The vector along which to project.\")" projected-points (point vector) (let ((parameter-pairs (surface-global-line-intersect *geometry-kernel* self point vector))) (mapcar #'(lambda(parameter-pair) (make-surface-point :uv-point (make-point (first parameter-pair) (second parameter-pair)) :3d-point (the (point (first parameter-pair) (second parameter-pair))))) parameter-pairs))) ("Surface point. Returns the first result of the given point projected along the given vector intersected with the surface. :arguments (point \"3D Point. The point to be projected.\" vector \"3D Vector. The vector along which to project.\")" projected-point (point vector) (let ((parameter-pair (first (surface-global-line-intersect *geometry-kernel* self point vector)))) (make-surface-point :uv-point (make-point (first parameter-pair) (second parameter-pair)) :3d-point (the (point (first parameter-pair) (second parameter-pair)))))) ("Plist. Returns plist containing :min and :max indicating min and max UV points for parameter space for this surface." domain () (surface-get-domain-components *geometry-kernel* self)) ("Number. Returns minimum U component of the surface parameter space." u-min () (get-x (getf (the domain) :min))) ("Number. Returns minimum V component of the surface parameter space." v-min () (get-y (getf (the domain) :min))) ("Number. Returns maximum U component of the surface parameter space." u-max () (get-x (getf (the domain) :max))) ("Number. Returns maximum V component of the surface parameter space." v-max () (get-y (getf (the domain) :max))) ("Boolean. Returns non-nil if the given UV (2D) point lies within the parameter space of this surface. Currently this function works only on the basis surface ; it does not observe trimming island or holes." on? (uv-point) (and (> (the u-max) (get-x uv-point) (the u-min)) (> (the v-max) (get-y uv-point) (the v-min)))) ("List of lists 3D points, List of lists numbers, List of numbers, List of numbers, Integer, and Integer. Returns six values which are the control points, the weights, the u-knots, the v-knots, the u-degree, and the v-degree of the surface." b-spline-data () (get-surface-b-spline-data *geometry-kernel* (the native-surface))) ("3D Point. The point on the surface corresponding to the given u and v parameter values." point (u v) (%get-point-on-surface *geometry-kernel* (the native-surface) u v)) ("3D Vector. The surface normal vector at the given u and v values. Three other values are also returned: The 3D point, the U tangent, and the V tangent at the given parameter value." normal (u v) (with-pinned-values ((u (the u-min) (the u-max)) (v (the v-min) (the v-max))) (get-surface-normal *geometry-kernel* (the native-surface) u v))) #+allegro ("Surface point. Returns the first point of intersection between this surface and the curve given as an argument. :arguments (curve \"GDL Curve object. The curve to intersect with this surface.\") :&key ((3d-tolerance *3d-tolerance-default*) \"Number. The tolerance to use for intersecting.\")" curve-intersection-point (curve &key (3d-tolerance *3d-tolerance-default*)) (let ((triplet (first (get-surface-curve-intersection-points *geometry-kernel* self curve :3d-tolerance 3d-tolerance)))) (when triplet (make-surface-point :parameter (first triplet) :uv-point (make-point (second triplet) (third triplet)) :3d-point (the (point (second triplet) (third triplet))))))) #+allegro ("List of Surface points. Returns the point(s) of intersection between this surface and the curve given as an argument. :arguments (curve \"GDL Curve object. The curve to intersect with this surface.\") :&key ((3d-tolerance *3d-tolerance-default*) \"Number. The tolerance to use for intersecting.\")" curve-intersection-points (curve &key (3d-tolerance *3d-tolerance-default*)) (let ((triplets (get-surface-curve-intersection-points *geometry-kernel* self curve :3d-tolerance 3d-tolerance))) (mapcar #'(lambda(triplet) (make-surface-point :parameter (first triplet) :uv-point (make-point (second triplet) (third triplet)) :3d-point (the (point (second triplet) (third triplet))))) triplets))))) (define-object brep-from-surface (brep) :input-slots (surface (end-caps? nil) sew-and-orient-brep?) :computed-slots ((%native-brep% (let ((brep (make-brep *geometry-kernel* :tolerance (the brep-tolerance)))) (make-faces-from-surface *geometry-kernel* brep (the surface) :continuity-type :c0 :end-caps? (the end-caps?)) (when (the sew-and-orient-brep?) (let ((status (iwbrep-sew-and-orient brep))) (format t "sew-and-orient status is: ~a.~%" status))) (unless (the brep-tolerance) (brep-reset-tolerance *geometry-kernel* brep)) brep))))
28,120
Common Lisp
.lisp
538
39.513011
142
0.587176
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4ba4cd9eb94e065e44ff6073aa969061c2a4f327220fcfaa1e907b57da02acac
35,844
[ -1 ]
35,845
spiral-curve.lisp
lisp-mirror_gendl/surf/source/spiral-curve.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object spiral-curve (curve) :documentation (:description "This object approximates a spiral around the Z axis using a cubic NURBS (b-spline-curve)." :author "Dave Cooper, Genworks International") :input-slots ("Number. The height of the spiral." height "Number. Initial radius at Z=0." radius-1 "Number. Final radius at z=height." radius-2 ("Keyword Symbol, :right or :left. Defaults to :right." right-or-left :right) "Number. The number of turns (1 = 360 degrees) in the spiral." number-of-turns ("Number. The amount by which to divide the height of the curve-in to compute the default tolerance. Default is 1000." tolerance-divisor 1000) ("Number. The tolerance to use for non-rational approximation of a rational curve-in. Defaults to the height divided by the tolerance-divisor." tolerance (div (the height) (the tolerance-divisor)))) :computed-slots ((native-curve (make-spiral *geometry-kernel* (to-double-float (the height)) (to-double-float (the radius-1)) (to-double-float (the radius-2)) (to-double-float (the number-of-turns)) (ecase (the right-or-left) (:right 0) (:left 1)) (to-double-float (the tolerance)))))) ;; ;; FLAG -- add to Lift tests. ;; (define-object spiral-curve-test (base-object) :computed-slots () :objects ((spiral-curve :type 'surf::spiral-curve :height 10.0 :radius-1 2.0 :radius-2 2.0 :number-of-turns 2.0 :right-or-left :right :tolerance 0.001) (boxed-1 :type 'boxed-curve :curve-in (the spiral-curve) :center (translate (the center) :left 10)) (boxed-2 :type 'boxed-curve :curve-in (the spiral-curve) :orientation (alignment :top (the (:face-normal-vector :rear))))))
2,671
Common Lisp
.lisp
64
37.625
122
0.708171
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e7acf0f1326d60b8ff4b75061cae853e5f5bd1adcecd769244d429af579350ad
35,845
[ -1 ]
35,846
composed-curve.lisp
lisp-mirror_gendl/surf/source/composed-curve.lisp
;; ;; Copyright 2002, 2009 Genworks International and Genworks BV ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object composed-curve (curve) :documentation (:description "Creates a single NURBS curve from a list (ordered or unordered) NURBS curves. If the result is more than one curve, this object will throw an error and you should use <tt>composed-curves</tt> instead." :examples "<pre> (in-package :gdl-user) (define-object test-global-filleted-polyline-curves (global-filleted-polyline-curves) :computed-slots ((default-radius 5) (vertex-list (list (make-point 0 0 0) (make-point 10 10 0) (make-point 30 10 0) (make-point 40 0 0) (make-point 30 -10 0) (make-point 10 -10 0) (make-point 0 0 0)))) :hidden-objects ((points :type 'point :sequence (:size (length (rest (the vertex-list)))) :center (nth (the-child index) (rest (the vertex-list)))) (view :type 'base-view :page-width (* 5 72) :page-height (* 5 72) :objects (cons self (list-elements (the points)))))) (define-object test-composed-curve (composed-curve) :computed-slots ((curves (the filleted-polyline-curves ordered-curves))) :hidden-objects ((filleted-polyline-curves :type 'test-global-filleted-polyline-curves))) (generate-sample-drawing :objects (the-object (make-object 'test-composed-curve)) :projection-direction (getf *standard-views* :trimetric)) </pre>") :input-slots ("List of GDL curve objects. These are the curves to be composed into a single curve." curves ("Number. Distance two curve endpoints can be apart and be considered coincident, the composite will be built without doing anything to the endpoints. Default is 0.01. Note: This input-slot must be non-zero." coincident-point-tolerance 0.01) ("Number. Distance two curve endpoints can be apart and have a linear curve segment automatically added between the points. Default is 0.1." distance-to-create-line 0.1) (native-curve-iw (if (null (the curves)) (error "Trying to construct a composed curve from an empty list of curves. Root path is ~s...~%" (the root-path)) (let ((result (build-composites-from-curves *geometry-kernel* (the curves) :distance-to-create-line (the distance-to-create-line) :same-point-tolerance (the coincident-point-tolerance)))) (if (consp (rest result)) (error "Composing resulted in ~a curves. Please use composed-curves instead.~%" (length result)) (first result))))))) (define-object composed-curves (base-object) :documentation (:description "Creates multiple NURBS curves by composing a list (ordered or unordered) NURBS curves. If the result is expected to be a single curve, you may wish to use <tt>composed-curve</tt> instead.") :input-slots ("List of GDL curve objects. These are the curves to be composed into a single curve." curves-in ("Number. Distance two curve endpoints can be apart and be considered coincident, the composite will be built without doing anything to the endpoints. Default is 0.01. Note: This input-slot must be non-zero." coincident-point-tolerance 0.01) ("Number. Distance two curve endpoints can be apart and have a linear curve segment automatically added between the points. Default is 0.1." distance-to-create-line 0.1)) :computed-slots ((native-curves-iw (build-composites-from-curves *geometry-kernel* (the curves-in) :distance-to-create-line (the distance-to-create-line) :same-point-tolerance (the coincident-point-tolerance)))) :objects (("Sequence of GDL Curve Objects. The curves resulting from composition." curves :type 'curve :sequence (:size (length (the native-curves-iw))) :native-curve-iw (nth (the-child index) (the native-curves-iw))))) ;;(define-object test-composed-curve (composed-curve) ;; :computed-slots ;; ((curves (the filleted-polyline-curves ordered-curves))) ;; ;; :hidden-objects ;; ((filleted-polyline-curves :type 'test-global-filleted-polyline-curves)))
5,452
Common Lisp
.lisp
98
45.561224
144
0.654337
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
81648546fdaab2e60f0acc50a2fbd3ff7819ea6161de0d059cce05e9e2273a74
35,846
[ -1 ]
35,847
ordered-curves.lisp
lisp-mirror_gendl/surf/source/ordered-curves.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (defun ordered-curves (curves &key (start (when curves (the-object (first curves) start))) (closed? nil) (tolerance *3d-approximation-tolerance-default*) (distance-to-create-line 0.001)) (the-object (make-object 'ordered-curves :curves curves :start start :closed? closed? :tolerance tolerance :distance-to-create-line distance-to-create-line) ordered-list)) (define-object ordered-curves (curve) :input-slots (curves (start (when (the curves) (the-object (first (the curves)) start))) (closed? nil) (tolerance 0.01) (distance-to-create-line 0.001)) :computed-slots ((ordered-list (cons (the built-from) (let ((rest (unless (typep (the rest-chain) 'null-part) (the rest-chain ordered-list)))) (if (typep (the connector) 'null-part) rest (cons (the connector) rest))))) (built-from (first (ensure-list (the first-curve)))) (first-curve (dolist (curve (the curves)) (when (coincident-point? (the start) (the-object curve start) :tolerance (the tolerance)) (return curve)) (when (coincident-point? (the start) (the-object curve end) :tolerance (the tolerance)) (return (list (the-object curve reverse) curve))))) (rest-curves (cond ((consp (the first-curve)) (remove (second (the first-curve)) (the curves))) ((the first-curve) (remove (the first-curve)(the curves))) (t (error "start point not found among curves in curve-chainer"))))) :objects ((connector :type (cond ((and (the rest-curves) (coincident-point? (the first-curve end) (the rest-chain built-from start) :tolerance (the distance-to-create-line))) 'null-part) ((null (the rest-curves)) 'null-part) (t 'linear-curve)) :start (the built-from end) :end (when (the rest-curves) (the rest-chain built-from start))) (rest-chain :type (if (the rest-curves) 'ordered-curves 'null-part) :curves (the rest-curves) :start (the first-curve end) :tolerance (the tolerance))))
3,826
Common Lisp
.lisp
72
36.208333
107
0.53963
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
34769e7092f0a1f1ccb08105734f7a7b891ad8af58fe996282f3542e1935e211
35,847
[ -1 ]
35,848
sewn-solid.lisp
lisp-mirror_gendl/surf/source/sewn-solid.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object sewn-solid (brep) :input-slots (surfaces) :computed-slots ((%native-brep% (let ((brep (make-brep *geometry-kernel* :tolerance (the brep-tolerance)))) (dolist (surface (the surfaces)) (make-faces-from-surface *geometry-kernel* brep surface)) (iwbrep-sew-and-orient brep) brep))))
1,355
Common Lisp
.lisp
29
38.62069
96
0.672713
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0eb6ed1b131e238ddb9c6c72c99b5d8579e6f62574a7fbbb2dbd2e539dc8e83b
35,848
[ -1 ]
35,849
utilities.lisp
lisp-mirror_gendl/surf/source/utilities.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (defun chain-nurbs-curves (curves &optional (start (when curves (the-object (first curves) start))) (closed? t) (tolerance 0.01)) (when curves (let ((start-match (position start curves :test #'(lambda(p1 p2) (coincident-point? p1 p2 :tolerance tolerance)) :key #'(lambda(obj) (the-object obj start)))) (end-match (position start curves :test #'(lambda(p1 p2) (coincident-point? p1 p2 :tolerance tolerance)) :key #'(lambda(obj) (the-object obj end))))) (cond ((and (not closed?) start-match end-match) (error "start matches both start and end of curve in chain-curves")) ((and (null start-match) (null end-match)) (print-variables start start-match end-match) (error "curves did not chain in chain-curves")) (start-match (cons (nth start-match curves) (chain-nurbs-curves (append (subseq curves 0 start-match) (subseq curves (1+ start-match))) (the-object (nth start-match curves) end) closed?))) (end-match (cons (the-object (nth end-match curves) reverse) (chain-nurbs-curves (append (subseq curves 0 end-match) (subseq curves (1+ end-match))) (the-object (nth end-match curves) start) closed?))))))) (defmethod evaluate-object ((category (eql :gdl-geometry-kernel-instance)) args) (let ((self (apply #'make-object 'native-reader args))) ;; ;; FLAG -- pull individual smlib object from the reader ;; (cond ((not (zerop (the curves number-of-elements))) (the (curves 0))) ((not (zerop (the surfaces number-of-elements))) (the (surfaces 0))) ((not (zerop (the breps number-of-elements))) (the (breps 0)))))) #+nil (define-object basis-copy (b-spline-surface) :input-slots ("GDL Surface. Surface to provide the source basis data." built-from) :computed-slots ((b-spline-data (multiple-value-list (the built-from b-spline-data))) (control-points (first (the b-spline-data))) (weights (second (the b-spline-data))) (u-knot-vector (third (the b-spline-data))) (v-knot-vector (fourth (the b-spline-data))) (u-degree (fifth (the b-spline-data))) (v-degree (sixth (the b-spline-data))))) #+nil (define-object ordered-curves (curve) :input-slots (curves (start (when (the curves) (the-object (first (the curves)) start))) (closed? nil) (tolerance 0.01)) ;;:computed-slots ((ordered-list (cons (the first-curve) (unless (typep (the rest-chain) 'null-part) (the rest-chain ordered-list)))) (built-from (first (ensure-list (the first-curve)))) (first-curve (dolist (curve (the curves)) (when (coincident-point? (the start) (the-object curve start) :tolerance (the tolerance)) (return curve)) (when (coincident-point? (the start) (the-object curve end) :tolerance (the tolerance)) (return (list (the-object curve reverse) curve))))) (rest-curves (cond ((consp (the first-curve)) (remove (second (the first-curve)) (the curves))) ((the first-curve) (remove (the first-curve)(the curves))) (t (error "start point not found among curves in curve-chainer"))))) ;;:objects ((rest-chain :type (if (the rest-curves) 'ordered-curves 'null-part) :curves (the rest-curves) :start (the first-curve end) :tolerance (the tolerance)))) #+nil (define-object curve-chain (curve) ;;:input-slots #+nil (curves (start (when (the curves) (the-object (first (the curves)) start))) (closed? nil) (tolerance 0.01)) ;;:computed-slots #+nil ((ordered-list (cons (the first-curve) (unless (typep (the rest-chain) 'null-part) (the rest-chain ordered-list)))) (built-from (first (ensure-list (the first-curve)))) (first-curve (dolist (curve (the curves)) (when (coincident-point? (the start) (the-object curve start) :tolerance (the tolerance)) (return curve)) (when (coincident-point? (the start) (the-object curve end) :tolerance (the tolerance)) (return (list (the-object curve reverse) curve))))) (rest-curves (cond ((consp (the first-curve)) (remove (second (the first-curve)) (the curves))) ((the first-curve) (remove (the first-curve)(the curves))) (t (error "start point not found among curves in curve-chainer"))))) ;;:objects #+nil ((rest-chain :type (if (the rest-curves) 'curve-chain 'null-part) :curves (the rest-curves) :start (the first-curve end) :tolerance (the tolerance))))
6,659
Common Lisp
.lisp
131
36.458015
99
0.551312
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
4bba23a76b6aa5fbfd5a1d91ead604cf28864a5e4fcdaf1c88a53c03203d34b4
35,849
[ -1 ]
35,850
boolean.lisp
lisp-mirror_gendl/surf/source/boolean.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object boolean-tolerance-mixin () :documentation (:description "Implements adaptive tolerancing for certain brep objects.") :input-slots (("Number. Defaults to *approximation-tolerance-factor*. This is multiplied by the minimum of the adaptive-tolerance of any of the input breps to produce the approximation-tolerance-adaptive." approximation-tolerance-factor (or *approximation-tolerance-factor* 5)) ("Number. Defaults to the minimum of the adaptive-tolerance of any of the input breps, multiplied by the approximation-tolerance-factor, rounded to nearest multiple of tenths (e.g. it will be 0.01, 0.001, 0.001), however if this evaluates as zerop, *3d-approximation-tolerance-default* will be used instead." approximation-tolerance-adaptive (* (the approximation-tolerance-factor) (let ((first-tolerance (the first-brep adaptive-tolerance))) (if (the rest-breps) (max first-tolerance (apply #'max (mapsend (the rest-breps) :adaptive-tolerance))) first-tolerance)))) ("Number. Defaults to *3d-approximation-tolerance-default* if non-nil. If this value is nil, then this defaults to the approximation-tolerance-adaptive." approximation-tolerance (or *boolean-operation-tolerance-default* (the approximation-tolerance-adaptive)))) :computed-slots ((first-brep (let ((brep (cond ((the brep) (the brep)) ((consp (the other-brep)) (first (the other-brep))) (t (error "If no brep is given, other-brep must be a list of breps."))))) (the (ensure-brep brep)))) (rest-breps (let ((breps (cond ((the brep) (ensure-list (the other-brep))) (t (rest (ensure-list (the other-brep))))))) (mapcar #'(lambda(brep) (the (ensure-brep brep))) breps)))) :functions ((ensure-brep (brep) (if (typep brep 'brep) brep (let ((brep (ignore-errors (the-object brep brep)))) (if (typep brep 'brep) brep (error "Given brep must be of type brep, or contain an object of type brep."))))))) (define-object boolean-merge (boolean-tolerance-mixin brep) :documentation (:description "Generalized Merge container for doing boolean operations. This is not to be used directly, but is mixed into subtracted-solid, united-solid, intersected-solid, and separated-solid. The specific operation is specified in the respective subclass.") :input-slots ( ("GDL Brep object or object containing a brep. First of the breps to be merged" brep nil) "GDL Brep object or object containing a brep, or list of brep objects or object containing a brep. Second (or rest) of the breps to be merged into the given <tt>brep</tt>" other-brep operation ("Boolean. If set to non-nil, throw warning but not error if any of the input breps has more than one non-infinite region. Defaults to *boolean-allow-multiple-regions?*, which itself defaults to nil." allow-multiple-regions? *boolean-allow-multiple-regions?*) ("Boolean. If set to non-nil, we throw an error instead of a warning if the resulting brep does not pass the built-in validation test. If nil, we throw a warning but continue to return the resulting brep. Defaults to *boolean-error-on-invalid-brep?* which itself defaults to t." error-on-invalid? *boolean-error-on-invalid-brep?*) ("Number. Defaults to *angle-tolerance-radians-default*." angle-tolerance *angle-tolerance-radians-default*) ("Boolean. Indicates whether we should try to sew and orient the resulting brep. This defaults to t for merge operation and nil otherwise." sew-and-orient? (eql (the operation) :merge)) ;; ;; FLAG -- remove this defunct version. ;; #+nil ("Boolean. Indicates whether we should try to sew and orient the resulting brep. Usually a good idea and this is defaulted to t, except for merged-solid where we default this to nil." sew-and-orient? t) (manifold? t)) :computed-slots ((%merge-and-brep (progn (when (or (> (the first-brep regions number-of-elements) 2) (not (every #'(lambda(number) (<= number 2)) (mapcar #'(lambda(object) (the-object object regions number-of-elements)) (the rest-breps))))) (let ((message (format nil "~%~%in ~a -~%~%Attempting booleans where brep has ~~a non-infinite regions.~%" (cons 'the (reverse (the root-path)))))) (if (the allow-multiple-regions?) (warn message (1- (the first-brep regions number-of-elements))) (error message (1- (the first-brep regions number-of-elements)))))) (let ((count -1) (length (length (the rest-breps))) merge-container current-breps (current-brep (the first-brep %native-brep%))) (dolist (other-brep (the rest-breps)) (incf count) (when *debug?* (print-variables (the root-path) (the first-brep root-path) (the-object other-brep root-path))) (when *debug?* (print-variables (the approximation-tolerance) (the angle-tolerance))) (setq merge-container (make-merge-container *geometry-kernel* current-brep (the-object other-brep %native-brep%) (the approximation-tolerance) (the angle-tolerance))) (ecase (the operation) ((:difference :union :intersection) (setq current-brep (do-boolean-merge-operation *geometry-kernel* merge-container (the operation) (the make-manifold?) :sew-and-orient? (the sew-and-orient?)))) ((:merge) (let ((try-manifold? (and (the make-manifold?) (= count (1- length))))) (setq current-brep (do-boolean-merge-operation *geometry-kernel* merge-container (the operation) try-manifold? :make-manifold? try-manifold? :sew-and-orient? (the sew-and-orient?))))) (:extract_separate (setq current-breps (do-boolean-separate-operation *geometry-kernel* merge-container (the make-manifold?) (the sew-and-orient?)))))) (ecase (the operation) ((:difference :union :intersection :merge) (list :merge-container merge-container :native-brep current-brep)) (:extract_separate (list :merge-container merge-container :native-breps current-breps)))))) ;; ;; FLAG -- remove this defunct version. ;; #+nil (%merge-and-brep (progn (when (or (> (the first-brep regions number-of-elements) 2) (not (every #'(lambda(number) (<= number 2)) (mapcar #'(lambda(object) (the-object object regions number-of-elements)) (the rest-breps))))) (let ((message (format nil "~%~%in ~a -~%~%Attempting booleans where brep has ~~a non-infinite regions.~%" (cons 'the (reverse (the root-path)))))) (if (the allow-multiple-regions?) (warn message (1- (the first-brep regions number-of-elements))) (error message (1- (the first-brep regions number-of-elements)))))) (let ((count -1) (length (length (the rest-breps))) merge-container current-breps (current-brep (the first-brep %native-brep%))) (dolist (other-brep (the rest-breps)) (incf count) (when *debug?* (print-variables (the root-path) (the first-brep root-path) (the-object other-brep root-path))) ;;(the first-brep assert-valid) ;;(the-object other-brep assert-valid) (when *debug?* (print-variables (the approximation-tolerance) (the angle-tolerance))) (setq merge-container (make-merge-container *geometry-kernel* current-brep (the-object other-brep %native-brep%) (the approximation-tolerance) (the angle-tolerance))) (ecase (the operation) ((:difference :union :intersection) (setq current-brep (do-boolean-merge-operation *geometry-kernel* merge-container (the operation) (the manifold?) :sew-and-orient? nil ;;(the sew-and-orient?) ))) ((:merge) (print-variables count length) (let ((try-manifold? (= count (1- length)))) (setq current-brep (do-boolean-merge-operation *geometry-kernel* merge-container (the operation) try-manifold? :make-manifold? try-manifold? :sew-and-orient? (the sew-and-orient?))))) (:extract_separate (setq current-breps (do-boolean-separate-operation *geometry-kernel* merge-container (the manifold?) (the sew-and-orient?)))))) ;; ;;(tag-edges *geometry-kernel* current-brep (get-long *geometry-kernel* current-brep)) ;; (ecase (the operation) ((:difference :union :intersection :merge) (list :merge-container merge-container :native-brep current-brep)) (:extract_separate (list :merge-container merge-container :native-breps current-breps)))))) (%native-brep% (progn (when (or (> (the first-brep regions number-of-elements) 2) (not (every #'(lambda(number) (<= number 2)) (mapcar #'(lambda(object) (the-object object regions number-of-elements)) (the rest-breps))))) (let ((message (format nil "~%~%in ~a -~%~%Attempting booleans where brep has ~~a non-infinite regions.~%" (cons 'the (reverse (the root-path)))))) (if (the allow-multiple-regions?) (warn message (1- (the first-brep regions number-of-elements))) (error message (1- (the first-brep regions number-of-elements)))))) (if (and (the first-brep) (null (the rest-breps))) (progn (warn "Boolean operation invoked on a single brep, this has no effect and returns the original brep. This occured in: ~s~%~%" (cons 'the (reverse (the root-path)))) (the first-brep %native-brep%)) (let ((result (closed-boolean-operation *geometry-kernel* ;;:object self :first-brep (the first-brep) :rest-breps (the rest-breps) :operation (the operation) :approximation-tolerance (the approximation-tolerance) :angle-tolerance (the angle-tolerance) :sew-and-orient? (the sew-and-orient?) :manifold? (the manifold?)))) ;; ;; FLAG - try to put this back in on a more selective basis. It's too slow with SMLib8.69 and later. ;; ;;(brep-assert-valid *geometry-kernel* result :warn? (not (the error-on-invalid?))) ;; result))))) :functions ((ensure-brep (brep) (if (typep brep 'brep) brep (let ((brep (ignore-errors (the-object brep brep)))) (if (typep brep 'brep) brep (error "Given brep must be of type brep, or contain an object of type brep."))))))) (define-object merged-solid (boolean-merge) :documentation (:description "Given two brep solids or a brep solid and an open face represented as a brep, performs a merge operation. Optionally (with make-manifold? t) makes the result manifold by trimming and throwing away extra pieces of faces and edges.") :input-slots (("Boolean. Indicates whether the resulting brep should be made into a manifold brep, with one or more regions." make-manifold? nil) ("Boolean. Indicates whether we should try to sew and orient the resulting brep. Usually a good idea and this is defaulted to t, except for merged-solid where we default this to nil." sew-and-orient? nil)) :computed-slots (;;(manifold? nil) (%native-brep% (getf (the %merge-and-brep) :native-brep)) (operation :merge))) (define-object separated-solid (base-object surf::boolean-tolerance-mixin) :documentation (:description "Given two brep solids or a brep solid and an open face represented as a brep, performs a split operation") :input-slots (brep other-brep) :computed-slots ((any-manifold-breps? (plusp (the regioned breps number-of-elements))) (new-faces (remove-if #'(lambda(face) (equalp (the-object face bounding-box) (the other-brep bounding-box))) (list-elements (the merged face-breps))))) :objects ((breps :type 'brep :sequence (:size (if (the any-manifold-breps?) (the regioned breps number-of-elements) (length (the new-faces)))) :display-controls (append (the display-controls) (the-child built-from display-controls)) :built-from (if (the any-manifold-breps?) (the regioned (breps (the-child index))) (nth (the-child index) (the new-faces))))) :hidden-objects ((merged :type 'merged-solid :pass-down (brep other-brep approximation-tolerance)) (regioned :type 'regioned-solid :brep (the merged)))) #+nil (define-object separated-solid-2 (base-object boolean-tolerance-mixin) :input-slots (brep other-brep) :objects ((breps :type 'brep :sequence (:size (the regioned breps number-of-elements)) :display-controls (the-child built-from display-controls) :built-from (the regioned (breps (the-child index))))) :hidden-objects ((merged :type 'merged-solid :pass-down (brep other-brep approximation-tolerance)) (regioned :type 'regioned-solid :brep (the merged)))) #+nil (define-object separated-solid (boolean-merge) :documentation (:description "Given two brep solids or a brep solid and an open face represented as a brep, performs a split operation") :input-slots (("Boolean. Indicates whether the resulting split pieces should be made into watertight solids (ends capped, etc)." cap-results? nil) ("List of Color Keywords. These indicate the colors for any child breps if the boolean operation results in a separated solid. If the number of breps exceeds the length of this list, the colors will be repeated in order. Defaults to a list with keys: <ul> <li> :green </li> <li> :red </li> <li> :blue </li> <li> :purple-dark </li> <li> :violet </li> <li> :cyan. </li> </ul>" section-colors (list :red :orange :gold-old :green :blue :purple-dark :violet))) :computed-slots ((operation :extract_separate) (number-of-colors (length (the section-colors))) ( ;;native-array-and-breps native-breps (closed-boolean-separate-operation *geometry-kernel* :first-brep (the first-brep) :other-brep (the other-brep%) :approximation-tolerance (the approximation-tolerance) :angle-tolerance (the angle-tolerance) :manifold? (the manifold?))) #+nil (native-breps (second (the native-array-and-breps))) ;; ;; FLAG -- following kept just for garbage finalization - not really needed as separate slot: ;; ;;(native-array (first (the native-array-and-breps))) (other-brep% (cond ((= (length (the rest-breps)) 1) (first (the rest-breps))) (t (the united-rest-breps))))) :objects (("Sequence of GDL brep objects. The resulting breps yielded from the separate operation. These are colored using section-colors." breps :type 'brep :sequence (:size (the open-breps number-of-elements)) :pseudo-inputs (%native-brep% display-controls) :display-controls (append (the display-controls) (list :color (nth (mod (the-child index) (the number-of-colors)) (the section-colors)))) :%native-brep% (if (the cap-results?) (the (capped-breps (the-child index)) %native-brep%) (the (open-breps (the-child index)) %native-brep%)))) :hidden-objects ((united-rest-breps :type 'united-solid :pass-down (approximation-tolerance angle-tolerance) :other-brep (the rest-breps)) (open-breps :type 'brep :pseudo-inputs (display-controls %native-brep%) :display-controls (list :color (nth (mod (the-child index) (the number-of-colors)) (the section-colors))) ;;:sequence (:size (length (getf (the %merge-and-brep) :native-breps))) ;;:%native-brep% (nth (the-child index) (getf (the %merge-and-brep) :native-breps)) :sequence (:size (length (the native-breps))) :%native-brep% (nth (the-child index) (the native-breps)) ) (capped-breps :type 'united-solid :sequence (:size (the open-breps number-of-elements)) :display-controls (list :color (nth (mod (the-child index) (the number-of-colors)) (the section-colors))) :allow-multiple-regions? (the allow-multiple-regions?) :brep (the (open-breps (the-child index))) :other-brep (the cap-face)) (cap-face :type 'intersected-solid :allow-multiple-regions? (the allow-multiple-regions?) :brep (the brep) :other-brep (the other-brep)))) (define-object subtracted-solid (boolean-merge) :documentation (:description "Given two brep solids, performs the subtract Boolean of the other-brep from the brep") :computed-slots ((operation :difference))) (define-object united-solid (boolean-merge) :documentation (:description "Given two brep solids, performs the union Boolean between the brep and the other-brep") :computed-slots ((operation :union))) (define-object intersected-solid (boolean-merge) :documentation (:description "Given two brep solids, performs the intersect Boolean between the brep and the other-brep") :computed-slots ((operation :intersection))) (define-object regioned-solid (base-object) :documentation (:description "Given a brep solid that contains multiple regions, splits the regions into separate breps") :input-slots ("GDL Brep object or object containing a brep. The multi-region brep to be split." brep (hide-faces? t) ("List of Color Keywords. These indicate the colors for any child breps if the regioning operation results in multiple solids. Defaults to a repeating (circular) list with keys: <ul> <li> :green </li> <li> :red </li> <li> :blue </li> <li> :purple-dark </li> <li> :violet </li> <li> :cyan. </li> </ul> " section-colors (list :green :red :blue :purple-dark :violet :cyan))) :computed-slots ((filled-regions (get-filled-regions *geometry-kernel* (the (ensure-brep (the brep))))) (number-of-colors (length (the section-colors)))) :objects ((breps :type 'brep :pass-down (hide-faces?) :sequence (:size (length (the filled-regions))) :pseudo-inputs (hide-faces? display-controls %native-brep%) :display-controls (append (the display-controls) (list :color (nth (mod (the-child index) (the number-of-colors)) (the section-colors)))) :%native-brep% (make-brep-from-regions *geometry-kernel* (the brep) (list (nth (the-child index) (the filled-regions)))))) :functions ((ensure-brep (brep) (if (typep brep 'brep) brep (let ((brep (ignore-errors (the-object brep brep)))) (if (typep brep 'brep) brep (error "Given brep must be of type brep, or contain an object of type brep."))))))) (define-object manifold-solid (brep) :documentation (:description "Attempts to take in a non-manifold brep and yield a manifold version.") :input-slots ("GDL brep object. The brep to be represented as a manifold brep in this instance." brep ("Boolean. Indicates whether faces between two non-void regions should be kept. Defaults to nil." keep-internal-faces? nil)) :computed-slots ((%native-brep% (make-brep-manifold *geometry-kernel* (the brep %native-brep%) ;; ;; FLAG -- suspect finalization ;; :finalize-on self :regions-to-keep nil :keep-internal-faces? (the keep-internal-faces?))))) (define-object brep-intersect (base-object) :documentation (:description "This primitive takes two brep objects and attempts to intersect the faces of the one with the faces of the other, yielding a sequence of edges which also behave as curves.") :input-slots ("Object of type brep. The first brep for intersecting its faces." brep "Object of type brep. The other brep for intersecting faces." other-brep ("Number. Defaults to the max of the adaptive-tolerance of any of the input breps." approximation-tolerance (let ((first-tolerance (the first-brep adaptive-tolerance))) (if (the rest-breps) (max first-tolerance (apply #'max (mapsend (the rest-breps) :adaptive-tolerance))) first-tolerance))) ("Number. Defaults to (radians-to-degrees *angle-tolerance-radians-default*)." angle-tolerance (radians-to-degrees *angle-tolerance-radians-default*)) ("Boolean. Should edges be children or hidden-children? Defaults to nil which makes them display as children." hide-edges? nil) ("Boolean. Should points be children or hidden-children? Defaults to nil which makes them display as children." hide-points? nil) ) :computed-slots ((first-brep (the brep)) (rest-breps (list (the other-brep))) (edges-and-points (multiple-value-list (brep-intersect *geometry-kernel* (the brep %native-brep%) (the other-brep %native-brep%) :tolerance (the approximation-tolerance) :angle-tolerance (the angle-tolerance))))) :objects ((edges :type 'curve :hidden? (the hide-edges?) :sequence (:size (length (first (the edges-and-points)))) :native-curve-iw (nth (the-child index) (first (the edges-and-points)))) (points :type 'point :hidden? (the hide-points?) :sequence (:size (length (second (the edges-and-points)))) ;; ;; FLAG -- when is this really needed? ;; :pseudo-inputs (%native-edge%) :%native-edge% (nth (the-child index) (second (the edges-and-points))))))
26,488
Common Lisp
.lisp
488
39.985656
132
0.592255
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
150f17eb4e655841b2bd6e76461bce90786050e27da77ef10d5efdd159e58456
35,850
[ -1 ]
35,851
planar-surface.lisp
lisp-mirror_gendl/surf/source/planar-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object planar-surface (surface) :documentation (:description "Creates a flat quadrilateral surface specified by its four corner points." :examples "<pre> (in-package :surf) (define-object test-planar-surface (planar-surface) :computed-slots ((display-controls (list :color :fuchsia :transparency 0.5)) (p00 (make-point 0 0 0)) (p01 (make-point 0 1 0)) (p10 (make-point 1 0 0)) (p11 (make-point 1.5 1.5 0)))) (generate-sample-drawing :objects (make-object 'test-planar-surface) :projection-direction :trimetric) </pre>") :input-slots ("3D point. Front-left corner of the planar surface." p00 "3D point. Front-right corner of the planar surface." p01 "3D point. Rear-left corner of the planar surface." p10 "3D point. Rear-right corner of the planar surface." p11) :computed-slots ((native-surface (make-planar-surface *geometry-kernel* (the p00) (the p01) (the p10) (the p11))))) (define-object test-planar-surface (planar-surface) :computed-slots ((p00 (make-point 0 0 0)) (p01 (make-point 0 1 0)) (p10 (make-point 1 0 0)) (p11 (make-point 1.5 1.5 0))) :hidden-objects ((view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :width (* 5 72) :length (* 5 72) :objects (list self))))
2,296
Common Lisp
.lisp
53
38.037736
107
0.68464
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2676973f87cc16a83285c3d5b7456ee89474f52e4f51475910676d5d1050bb17
35,851
[ -1 ]
35,852
nonrational-curve.lisp
lisp-mirror_gendl/surf/source/nonrational-curve.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object non-rational-curve (curve) :documentation (:description "This object accepts a rational curve and approximates it with a non-rational curve." :author "Dave Cooper, Genworks International") :input-slots ("GDL Curve object. Presumably this is a Rational curve (else this object will do nothing)." curve-in ("Number. The amount by which to divide the total-length of the curve-in to compute the default tolerance. Default is 1000." tolerance-divisor 1000) ("Number. The tolerance to use for non-rational approximation of a rational curve-in. Defaults to the curve-in's total length divided by the tolerance-divisor." tolerance (div (the curve-in total-length) (the tolerance-divisor))) ("Boolean. Determines whether to try to maintain tangents at the ends. Defaults to t." maintain-end-tangents? t) ("Integer. Determines the degree of the non-rational curve. Defaults to 3." non-rational-degree 3) ("Keyword symbol, one of :uniform, :chord-length, :centripetal, or :inherited. The default is :inherited." parameterization :inherited)) :computed-slots ((native-curve (if (the curve-in rational?) (rational-to-nonrational *geometry-kernel* (the curve-in) :tolerance (the tolerance) :maintain-end-tangents? (the maintain-end-tangents?) :nonrational-degree (the non-rational-degree) :parameterization (the parameterization))))))
2,328
Common Lisp
.lisp
42
51.333333
128
0.740741
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fca0fc39c9855dea29a9e562781b0c66d0f09df54118d74147668c790d8e3ca0
35,852
[ -1 ]
35,853
offset-surface.lisp
lisp-mirror_gendl/surf/source/offset-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object offset-surface (surface) :documentation (:description "This primitive generates a new surface which is offset from input surface in all normal directions from input surface.") :input-slots ("GDL Surface object. The original surface from which to make the offset." surface-in "Number. The distance to offset. Positive or negative, depending on which direction you want." distance ("Keyword symbol, one of :uniform, :chord-length, :centripetal, or :inherited. The parameterization method used to re-fit the points after offsetting. Defaults to :uniform." parameterization :uniform) ("Integer. The desired u-degree of the resulting surface. Defaults to the u-degree of the input surface-in." u-degree (the surface-in u-degree)) ("Integer. The desired v-degree of the resulting surface. Defaults to the v-degree of the input surface-in." v-degree (the surface-in v-degree)) ("Number. The tolerance of approximation for the re-fitting of points after the offsetting. Defaults to *3d-approximation-tolerance-default*." approximation-tolerance *3d-approximation-tolerance-default*)) :computed-slots ((native-surface (make-offset-surface *geometry-kernel* :surface (the surface-in native-surface) :offset-distance (the distance) :u-degree (the u-degree) :v-degree (the v-degree) :parameterization (the parameterization) :tolerance (the approximation-tolerance))))) (define-object test-fitted-surface (fitted-surface) :input-slots ((display-controls (list :color :green-spring :isos (list :n-v 19 :n-u 19))) (grid-width 4 :settable) (grid-length 4 :settable) (grid-height 4 :settable)) :computed-slots ( (points (list (list (make-point 0 0 0) (make-point (/ (the grid-width) 4) 0 0) (make-point (half (the grid-width)) 0 0) (make-point (* 3/4 (the grid-width)) 0 0) (make-point (the grid-width) 0 0)) (list (make-point 0 (/ (the grid-length) 4) 0) (make-point (/ (the grid-width) 4) (/ (the grid-length) 4) (/ (the grid-height) 4)) (make-point (half (the grid-width)) (/ (the grid-length) 4) (* (/ (the grid-height) 4) 1.6)) (make-point (* 3/4 (the grid-width)) (/ (the grid-length) 4) (/ (the grid-height) 4)) (make-point (the grid-width) (/ (the grid-length) 4) 0)) (list (make-point 0 (half (the grid-length)) 0) (make-point (/ (the grid-width) 4) (half (the grid-length)) (* (/ (the grid-height) 4) 1.8)) (make-point (half (the grid-width)) (half (the grid-length)) (the grid-height)) (make-point (* 3/4 (the grid-width)) (half (the grid-length)) (* 3/4 (the grid-height))) (make-point (the grid-width) (half (the grid-length)) 0)) (list (make-point 0 (* 3/4 (the grid-length)) 0) (make-point (/ (the grid-width) 4) (* 3/4 (the grid-length)) (min (* (/ (the grid-height) 4) (* (/ (the grid-height) 4) 1.4)) (the grid-height))) (make-point (half (the grid-width)) (* 3/4 (the grid-length)) (min (* (/ (the grid-height) 4) (* (/ (the grid-height) 4) 1.8)) (the grid-height))) (make-point (* 3/4 (the grid-width)) (* 3/4 (the grid-length)) (/ (the grid-height) 4)) (make-point (the grid-width) (* 3/4 (the grid-length)) 0)) (list (make-point 0 (the grid-length) 0) (make-point (/ (the grid-width) 4) (the grid-length) 0) (make-point (half (the grid-width)) (the grid-length) 0) (make-point (* 3/4 (the grid-width)) (the grid-length) 0) (make-point (the grid-width) (the grid-length) 0)))))) (define-object test-offset-surface (base-object) :objects ((original :type 'test-fitted-surface) (offset :type 'offset-surface :surface-in (the original) :distance 0.5)))
5,627
Common Lisp
.lisp
90
47.055556
112
0.566642
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f95027a0f919047846978f8a716b7a79a4cde7616f7f0582f75f230bd60f5d81
35,853
[ -1 ]
35,854
fitted-curve.lisp
lisp-mirror_gendl/surf/source/fitted-curve.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) ;;(eval-when (:compile-toplevel :load-toplevel :execute) ;;XXX (define-object fitted-curve (curve) :documentation (:description "Fits a curve through a set of points with given degree and parameterization." :examples "<pre> (in-package :surf) (define-object test-fitted-curve (fitted-curve) :computed-slots ((points (the circle (equi-spaced-points 20)))) :hidden-objects ((circle :type 'circle :radius 10) (spheres :type 'sphere :sequence (:size (length (the points))) :radius 0.2 :center (nth (the-child :index) (the points)) :display-controls (list :color :blue-neon)))) (generate-sample-drawing :objects (let ((self (make-object 'test-fitted-curve))) (cons self (list-elements (the spheres))))) </pre>") :input-slots ("List of 3D Points. The points for fitting." points ("Integer. The desired degree of the resultant curve. Default is 3, unless there are fewer than four control point given, in which case it one less than the number of control points." degree (min (1- (length (the points))) 3)) ("List of 3D Vectors. Optional list of vectors used to influence the fitting. Default is NIL." vectors nil) ("Keyword symbol, one of <tt>:tangents</tt>, <tt>:normals</tt>, or <tt>:first-last</tt>. <tt>:Tangents</tt> indicates that the <tt>:vectors</tt> specify a tangent vector at each point (there should be one vector for each point), <tt>:normals</tt> indicates that the <tt>:vectors</tt> specify a normal vector at each point (there should be one vector for each point), and <tt>:first-last</tt> indicates that the <tt>:vectors</tt> specify the starting and ending tangent (in this case there should be two vectors in the <tt>:vectors</tt> list. Default is <tt>:tangents</tt>.)" vector-type :tangents) ("Keyword symbol, one of :uniform, :chord-length, :centripetal. The parameterization to use in the resultant curve. Default is :centripetal. Note that the NLib documentation states that when specifying vectors and a vector-type of <tt>:tangents</tt> or <tt>:first-last</tt>, <tt>:chord-length</tt> is a recommended value for parameterization. If vectors are used and the vector-type is <tt>:normals</tt>, this input has no effect. The default is <tt>:chord-length</tt>" parameterization :chord-length) ("Number or nil. The allowed tolerance for doing data reduction after the initial fitting. A <tt>nil</tt> value indicates that no data reduction is to be attempted. Defaults to nil." tolerance *3d-approximation-tolerance-default*) ("Boolean. Indicates whether the curve will interpolate the points. Defaults to T ." interpolant? t) (knot-multiplicity :multiple) ("Boolean. Indicates whether the inputted control-points should be considered in local coordinate system of this object. Default is nil." local? nil)) :computed-slots ((effective-points (if (the local?) (mapcar #'(lambda(point) (the (local-to-global point))) (the points)) (the points))) (effective-vectors (if (the local?) (mapcar #'(lambda(vector) (the (local-to-global vector))) (the vectors)) (the vectors))) (native-curve (progn (when (and (the vectors) (member (the vector-type) (list :tangents :normals)) (not (= (length (the points)) (length (the vectors))))) (error "For fitted-curve ~s, points and vectors must be lists of the same length.~%" (cons 'the (reverse (the root-path))))) ;; ;; FLAG -- consider the case of 2 fit points but resulting curve should have more control-points ;; based on given vectors... maybe this conditional is not valid. ;; (if (> (length (the points)) 2) (let ((degree-ok? (<= (the degree) (1- (length (the points)))))) (unless degree-ok? (error "The degree of a fitted-curve must be less than or equal to the number of control points.")) (interpolate-curve *geometry-kernel* (the effective-points) (the degree) (the parameterization) :vectors (the effective-vectors) :vector-type (the vector-type) :interpolant? (the interpolant?) :knot-multiplicity (the knot-multiplicity) :tolerance (the tolerance))) (the linear-curve native-curve)))) (%renderer-info% (list :vrml? t :view-default :top)) ) :hidden-objects ((linear-curve :type (if (= (length (the points)) 2) 'linear-curve 'null-part) :start (first (the points)) :end (second (the points))))) ;;)
5,891
Common Lisp
.lisp
100
49.17
156
0.660151
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
29edd517cc53cff5309660138ecb852add32c43c4ee39d5f3a5e3d30246efcb5
35,854
[ -1 ]
35,855
facial-brep.lisp
lisp-mirror_gendl/surf/source/facial-brep.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object facial-brep (brep) :input-slots (%source-native-brep% %native-face%) :computed-slots ((%native-brep% (copy-face-to-new-brep *geometry-kernel* (the %source-native-brep%) (the %native-face%)))))
1,230
Common Lisp
.lisp
26
39.884615
84
0.662732
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
8170bc5be32c64d6a6c329b3b6037c164ab5473c698f1501457f6e9e44a7472c
35,855
[ -1 ]
35,856
spherical-surface.lisp
lisp-mirror_gendl/surf/source/spherical-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) ;; ;; FLAG -- update to do spherical patches. ;; (define-object spherical-surface (surface sphere) :documentation (:description "A surface representation of the sphere. Takes the same inputs as native GDL sphere. Partial spheres are not yet implmented. Note that some VRML browsers, e.g. Cortona v. 4.2, show some spurious artifacts with NURBS created as spherical surfaces. BS Contact does not appear to have this problem." :examples "<pre> (in-package :surf) (define-object test-spherical-surface (spherical-surface) :computed-slots ((display-controls (list :color :sky-summer)) (radius 10))) (generate-sample-drawing :objects (make-object 'test-spherical-surface) :projection-direction :trimetric) </pre>") :input-slots ((center (make-point 0 0 0) :defaulting)) :computed-slots ((native-surface (make-spherical-surface *geometry-kernel* (the center) (the radius) 0 180 (radians-to-degrees (the end-horizontal-arc)) 2 2)))) (define-object test-spherical-surface (spherical-surface) :computed-slots ((radius 10)) :hidden-objects ((view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :width (* 5 72) :length (* 5 72) :objects (list self)))) (define-object test-spherical (base-object) :objects ((spherical :type 'test-spherical-surface) (view-1 :type 'generic-view :%curves-to-draw% (the spherical %curves-to-draw%)) (view-2 :type 'generic-view :%curves-to-draw% (the spherical brep %curves-to-draw%)))) (define-object generic-view (base-object) :input-slots (%curves-to-draw%)) (define-object test-spherical-surface-2 (spherical-surface) :computed-slots ((radius 10) (end-horizontal-arc (* 3/2 pi))))
2,866
Common Lisp
.lisp
59
41.050847
156
0.676546
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
073df21527ebad409b173aad0f7fbea4405b5eb8ae955f3b6d522522e6edc9c7
35,856
[ -1 ]
35,857
redirected-surface.lisp
lisp-mirror_gendl/surf/source/redirected-surface.lisp
(in-package :gdl-user) ;; ;; Copyright 2015 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object redirected-surface (b-spline-surface) :documentation (:description "Generates a new surface with U and V parameters swapped and/or reversed in their direction.") :input-slots ("GDL surface object" surface-in ("Boolean. Specifies whether existing U and V should be swapped before possibly reversing. Defaults to nil." swap-uv? nil) ("Boolean. Specifies whether resulting U parameter space should be reversed. Defaults to nil." reverse-u? nil) ("Boolean. Specifies whether resulting V parameter space should be reversed. Defaults to nil." reverse-v? nil)) :computed-slots ((control-points (the (transpose-and-reverse-as-needed (the surface-in control-points)))) (weights (the (transpose-and-reverse-as-needed (the surface-in weights)))) (u-degree (the surface-in u-degree)) (v-degree (the surface-in v-degree)) (u-knot-vector (the (swap-and-reverse-as-needed (the surface-in u-knot-vector) (the surface-in v-knot-vector) (the reverse-u?)))) (v-knot-vector (the (swap-and-reverse-as-needed (the surface-in v-knot-vector) (the surface-in u-knot-vector) (the reverse-v?))))) :functions ((transpose-and-reverse-as-needed (list-o-lists) (let* ((swapped (if (the swap-uv?) (apply #'mapcar #'list list-o-lists) list-o-lists)) (rows (if (the reverse-u?) (reverse swapped) swapped))) (if (the reverse-v?) (mapcar #'reverse rows) rows))) (swap-and-reverse-as-needed (u-knot-vector v-knot-vector reverse?) (cond ((and (the swap-uv?) reverse?) (the (reverse-knots v-knot-vector))) ((the swap-uv?) v-knot-vector) (reverse? (the (reverse-knots u-knot-vector))) (t u-knot-vector))) (reverse-knots (knot-vector) (let* ((min (first knot-vector)) (max (lastcar knot-vector))) (mapcar #'(lambda(knot) (let ((difference (- max knot))) (+ min difference))) (reverse knot-vector)))))) ;; ;; FLAG -- add to regression tests. ;; #+nil (in-package :gdl-user) #+nil (define-object test-redirected-surfaces (base-object) :input-slots ((n-u 12) (n-v 12)) :objects ((test-surface :type 'test-fitted-surface :display-controls (list :color :green :isos (list :n-u (the n-u) :n-v (the n-v)))) (swapped-uv :type 'surf::redirected-surface :surface-in (the test-surface) :swap-uv? t :display-controls (list :color :red :isos (list :n-u (the n-u) :n-v (the n-v)))) (swapped-uv-reverse-u :type 'surf::redirected-surface :surface-in (the test-surface) :swap-uv? t :reverse-u? t :display-controls (list :orange :green :isos (list :n-u (the n-u) :n-v (the n-v)))) (swapped-uv-reverse-v :type 'surf::redirected-surface :surface-in (the test-surface) :swap-uv? t :reverse-v? t :display-controls (list :color :yellow :isos (list :n-u (the n-u) :n-v (the n-v)))) (swapped-uv-reverse-uv :type 'surf::redirected-surface :surface-in (the test-surface) :swap-uv? t :reverse-v? t :reverse-u? t :display-controls (list :color :blue :isos (list :n-u (the n-u) :n-v (the n-v)))) (reverse-u :type 'surf::redirected-surface :surface-in (the test-surface) :reverse-u? t :display-controls (list :color :indigo :isos (list :n-u (the n-u) :n-v (the n-v)))) (reverse-v :type 'surf::redirected-surface :surface-in (the test-surface) :reverse-v? t :display-controls (list :color :violet :isos (list :n-u (the n-u) :n-v (the n-v)))) (reverse-uv :type 'surf::redirected-surface :surface-in (the test-surface) :reverse-v? t :reverse-u? t :display-controls (list :color :cyan :isos (list :n-u (the n-u) :n-v (the n-v))))))
4,676
Common Lisp
.lisp
113
36.584071
133
0.667478
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
b4160a8b615e3b1cf954bf887c83ce8bbf4dad44a5e5ef9b4c6c94e46df8a624
35,857
[ -1 ]
35,858
stitched-solid.lisp
lisp-mirror_gendl/surf/source/stitched-solid.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object stitched-solid (brep) :documentation (:description "Attempts to stitch together a list of surfaces into an open shell or possibly a manifold solid. This primitive is not widely tested and may be deprecated. Consider use of merged-solid instead. Please let Genworks know if you are using this so we can consider documenting/testing it better.") :input-slots ("List of GDL Surface or Face objects. These will be stitched together into an open shell or possibly a Solid" faces-in ("Number. The tolerance to use for creating the brep and for sewing. Larger number is looser tolerance and more likely to lead to success. Default is 0.0 which uses the SMLib defaults." tolerance 0.0)) :computed-slots ((plain-surfaces (remove-if #'(lambda (object)(typep object 'trimmed-surface)) (remove-if-not #'(lambda(object) (typep object 'surface)) (the faces-in)))) (trimmed-surfaces (remove-if-not #'(lambda (object)(typep object 'trimmed-surface)) (the faces-in))) (proper-faces (remove-if-not #'(lambda(object) (typep object 'face)) (the faces-in))) (%native-brep% (progn (when (or (the trimmed-surfaces) (the proper-faces)) (error "stitched-solid is currently only implemented for plain untrimmed surfaces")) (make-stitched-solid-brep *geometry-kernel* :tolerance (the tolerance) :surfaces (the plain-surfaces) :proper-faces nil))) ;; ;; FLAG -- remove this defunct version. ;; #+nil (%native-brep% (progn (when (or (the trimmed-surfaces) (the proper-faces)) (error "stitched-solid is currently only implemented for plain untrimmed surfaces")) (make-stitched-solid-brep *geometry-kernel* :surfaces (the plain-surfaces) :proper-faces nil))))) (define-object test-stitched-solid (stitched-solid) :computed-slots ((faces-in (list (the surface)))) :hidden-objects ((surface :type 'test-b-spline-surface))) (define-object test-stitched-solid-box (stitched-solid) :computed-slots ((length 20) (width 10) (height 10) (faces-in (list (the top-face) (the bottom-face) (the right-face) (the left-face) (the rear-face) (the front-face)))) :hidden-objects ((box :type 'box) (top-face :type 'planar-surface :p00 (the box (vertex :top :right :rear)) :p01 (the box (vertex :top :right :front)) :p10 (the box (vertex :top :left :rear)) :p11 (the box (vertex :top :left :front))) (bottom-face :type 'planar-surface :p00 (the box (vertex :bottom :right :rear)) :p01 (the box (vertex :bottom :right :front)) :p10 (the box (vertex :bottom :left :rear)) :p11 (the box (vertex :bottom :left :front))) (right-face :type 'planar-surface :p00 (the box (vertex :top :right :rear)) :p01 (the box (vertex :top :right :front)) :p10 (the box (vertex :bottom :right :rear)) :p11 (the box (vertex :bottom :right :front))) (left-face :type 'planar-surface :p00 (the box (vertex :top :left :rear)) :p01 (the box (vertex :top :left :front)) :p10 (the box (vertex :bottom :left :rear)) :p11 (the box (vertex :bottom :left :front))) (rear-face :type 'planar-surface :p00 (the box (vertex :top :right :rear)) :p01 (the box (vertex :top :left :rear)) :p10 (the box (vertex :bottom :right :rear)) :p11 (the box (vertex :bottom :left :rear))) (front-face :type 'planar-surface :p00 (the box (vertex :top :right :front)) :p01 (the box (vertex :top :left :front)) :p10 (the box (vertex :bottom :right :front)) :p11 (the box (vertex :bottom :left :front)))))
5,044
Common Lisp
.lisp
94
43.393617
113
0.622273
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
2dd8fc44b84d0e8286936d10313da7737c67f3167e44e772600848669ba02cd9
35,858
[ -1 ]
35,859
ruled-surface.lisp
lisp-mirror_gendl/surf/source/ruled-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object ruled-surface (surface) :documentation (:description "Creates a surface between two NURBS curves.:" :examples "<pre> (in-package :surf) (define-object test-ruled-surface (ruled-surface) :computed-slots ((display-controls (list :color :orchid-dark))) :hidden-objects ((curve-1 :type 'linear-curve :start (make-point -1 -1 0) :end (make-point -1 1 0)) (curve-2 :type 'fitted-curve :points (list (make-point 1 -1 0) (make-point 0 0 0) (make-point .5 .5 0) (make-point 1 2 0))))) (generate-sample-drawing :objects (make-object 'test-ruled-surface) :projection-direction :trimetric) </pre>") :input-slots ("GDL Curve object. First boundary of the ruled surface." curve-1 "GDL Curve object. Second boundary of the ruled surface." curve-2 ("Keyword symbol, either :u or :v. The direction of parameterization of the surface between the two curves." direction :u)) :computed-slots ((native-surface (make-ruled-surface *geometry-kernel* :curve-1 (the curve-1) :curve-2 (the curve-2) :direction (the direction))))) (define-object test-ruled-surface (ruled-surface) :hidden-objects ((curve-1 :type 'linear-curve :start (make-point -1 -1 0) :end (make-point -1 1 0)) (curve-2 :type 'fitted-curve :points (list (make-point 1 -1 0) (make-point 0 0 0) (make-point .5 .5 0) (make-point 1 2 0)))))
2,496
Common Lisp
.lisp
51
41.156863
134
0.662019
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
e84563ca212f9ce7e8869b722303b2428653e8ecddc3a263bb6569423d5bf4fa
35,859
[ -1 ]
35,860
brep.lisp
lisp-mirror_gendl/surf/source/brep.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object brep (geometry-kernel-object-mixin ifs-output-mixin base-object) :documentation (:description "A general superclass for all boundary representation geometric entities. This currently follows the smlib topology model, with breps containing regions, regions containing shells, and shells containing faces and edges. Shells which completely enclose a volume are considered to make up a solid brep." :author "Dave Cooper, Genworks" ) :input-slots ( (hide-faces? t) ("GDL Brep object. Defaults to nil. Specify this if you want this brep to be a clone of an existing brep. (note - this uses a shared underlying brep object, it does not make a copy)" built-from nil) (native-pointer nil) (%native-brep% (or (the native-pointer) (if (the built-from) (the built-from %native-brep%) (error "%native-brep% has to be passed in to brep or overridden in the subclass")))) ("Plist of keyword symbols and numbers. This controls tessellation for this brep. The keys are as follows: <ul> <li><tt>:min-number-of-segments</tt></li> <li><tt>:max-3d-edge-factor</tt></li> <li><tt>:min-parametric-ratio</tt></li> <li><tt>:max-chord-height</tt></li> <li><tt>:max-angle-degrees</tt></li> <li><tt>:min-3d-edge</tt></li> <li><tt>:min-edge-ratio-uv</tt></li> <li><tt>:max-aspect-ratio</tt></li> </ul> and the defaults come from the following parameters: <pre> (list :min-number-of-segments *tess-min-number-of-segments* :max-3d-edge-factor *tess-max-3d-edge-factor* :min-parametric-ratio *tess-min-parametric-ratio* :max-chord-height *tess-max-chord-height* :max-angle-degrees *tess-max-angle-degrees* :min-3d-edge *tess-min-3d-edge* :min-edge-ratio-uv *tess-min-edge-ratio-uv* :max-aspect-ratio *tess-max-aspect-ratio*) </pre> " tessellation-parameters (list :min-number-of-segments *tess-min-number-of-segments* :max-3d-edge-factor *tess-max-3d-edge-factor* :min-parametric-ratio *tess-min-parametric-ratio* :max-chord-height *tess-max-chord-height* :max-angle-degrees *tess-max-angle-degrees* :min-3d-edge *tess-min-3d-edge* :min-edge-ratio-uv *tess-min-edge-ratio-uv* :max-aspect-ratio *tess-max-aspect-ratio*)) ("Integer. Used for tessellations. Default comes from (the tessellation-parameters)." min-number-of-segments (getf (the tessellation-parameters) :min-number-of-segments) :settable) ("Number. Used for tessellations. Default comes from (the tessellation-parameters)." max-3d-edge-factor (getf (the tessellation-parameters) :max-3d-edge-factor) :settable) ("Number. Used for tessellations. Computed from (the max-extent) and (the max-3d-edge-factor). WARNING: Modify this value at your peril. Small values can cause intractable tessellations. It is better to tweak max-3d-edge-factor to a small value like 0.1, as this will be taken relative to the max-extent of the brep." max-3d-edge (* (the max-extent) (the max-3d-edge-factor)) :settable) ("Number. Used for tessellations. Default comes from (the tessellation-parameters)." min-parametric-ratio (getf (the tessellation-parameters) :min-parametric-ratio) :settable) ("Number. Used for tessellations. Default comes from (the tessellation-parameters)." max-chord-height (getf (the tessellation-parameters) :max-chord-height) :settable) ("Number. Used for tessellations. Default comes from (the tessellation-parameters)." max-angle-degrees (getf (the tessellation-parameters) :max-angle-degrees) :settable) ("Number. Used for tessellations. Default comes from (the tessellation-parameters)." min-3d-edge (getf (the tessellation-parameters) :min-3d-edge) :settable) ("Number. Used for tessellations. Default comes from (the tessellation-parameters)." min-edge-ratio-uv (getf (the tessellation-parameters) :min-edge-ratio-uv) :settable) ("Number. Used for tessellations. Default comes from (the tessellation-parameters)." max-aspect-ratio (getf (the tessellation-parameters) :max-aspect-ratio) :settable) ("Boolean. Smooth results for poly-brep? Defaults to t." poly-brep-smooth-results? t :settable) ("Number. The density per unit volume of the brep. Defaults to 1" density 1 :settable) ("Boolean. Determines whether the isoparametric curves of each face of the brep are used for wireframe display. The default is T." display-iso-curves-wireframe? (not *brep-wireframe-tessellation?*) :settable) ("Plist with keys :n-u and :n-v. The number of isoparametric curves to be displayed in each direction. This value comes from the value of :isos on the display-controls if that exists, and defaults to *isos-default* otherwise." isos (getf (the display-controls) :isos *brep-isos-default*) :settable) ("Boolean. Determines whether the tessellation grid-lines of the brep are used for wireframe display. The default is NIL." display-tessellation-lines-wireframe? *brep-wireframe-tessellation?* :settable) ("Number. Overall tolerance for the created brep solid. Defaults to nil. Note that a value of nil indicates for SMLib to use value of 1.0e-05 of the longest diagonal length of the brep." brep-tolerance *brep-tolerance-default*) ("List of Color Keywords. These indicate the colors for the breps produced by (the face-breps). If the number of face-breps exceeds the length of this list, the colors will be repeated in order. Defaults to a list with keys: <ul> <li> :green </li> <li> :red </li> <li> :blue </li> <li> :purple-dark </li> <li> :violet </li> <li> :cyan. </li> </ul>" face-brep-colors (list :red :orange :gold-old :green :blue :purple-dark :violet)) ) :computed-slots ( (ifs-array-and-indices (destructuring-bind (&key vertex-counts vertex-indices 3d-points &allow-other-keys) (the tessellation) (let ((coords-array (make-array (length 3d-points) :initial-contents 3d-points)) (indices-array (make-array (length vertex-indices) :initial-contents vertex-indices))) (list :array coords-array :indices (let ((position 0)) (mapcar #'(lambda(count) (prog1 (let (result) (dotimes (n count (nreverse result)) (push (aref indices-array (+ position n)) result))) (setq position (+ position count)))) vertex-counts)))))) (ifs-array (getf (the ifs-array-and-indices) :array)) (ifs-indices (getf (the ifs-array-and-indices) :indices)) (bounding-box (brep-calculate-tight-bounding-box *geometry-kernel* (the %native-brep%))) (max-extent (apply #'3d-distance (the bounding-box))) ("Number. This is the actual tolerance stored in the SMLib object." adaptive-tolerance (brep-get-tolerance *geometry-kernel* (the %native-brep%))) ;;(adaptive-tolerance (* *3d-approximation-tolerance-default* (the max-extent))) ("FLAG -- for debug testing only Plist with :min-x :max-x :min-y :max-y :min-z :max-z. Returns the extreme points of the bounding-box of the brep in each direction. This will be updated to return points on the brep itself, not necessarily the bounding box." min-max-x-y-z (let ((box (the bounding-box))) ;; ;; FLAG -- evaluate this just to see if it's the prob ;; (list :min-x (first box) :max-x (second box) :min-y (first box) :max-y (second box) :min-z (first box) :max-z (second box)))) #+nil ("Plist with :min-x :max-x :min-y :max-y :min-z :max-z. Returns the extreme points of the brep in each direction (on the brep itself, not necessarily on the bounding box)." min-max-x-y-z (let ((points (list-elements (the face-points) (the-element center)))) (list :min-x (least #'get-x points) :max-x (most #'get-x points) :min-y (least #'get-y points) :max-y (most #'get-y points) :min-z (least #'get-z points) :max-z (most #'get-z points)))) (%triangle-data% (let ((result (the (tessellation :in-memory? t)))) (mapcan #'(lambda(key val) (list key (if (consp val) (coerce val 'vector) val))) (plist-keys result) (plist-values result)))) ("List of Plists, one for each face, format still being determined. Contains triangle and connectivity data for the tessellation of this brep. Exact supported format will be documented here when ready." triangle-data (mapsend (the face-triangles) :triangle-data)) (one-face-data (list :vertex-counts (apply #'append (mapcar #'(lambda(tris) (coerce (the-object tris vertex-counts) 'list)) (list-elements (the face-triangles)))) :vertex-indices (apply #'append (mapcar #'(lambda(tris) (coerce (the-object tris full-vertex-indices) 'list)) (list-elements (the face-triangles)))) :3d-points (apply #'append (mapcar #'(lambda(tris) (coerce (the-object tris 3d-points) 'list)) (list-elements (the face-triangles)))) :uv-points (apply #'append (mapcar #'(lambda(tris) (coerce (the-object tris uv-points) 'list)) (list-elements (the face-triangles)))) :surface-normals (apply #'append (mapcar #'(lambda(tris) (coerce (the-object tris surface-normals) 'list)) (list-elements (the face-triangles)))))) ;; ;; FLAG -- make this work for in-memory!! ;; (%tess-data% (the (tessellation :in-memory? nil))) ;; ;; FLAG -- copied back from base-object -- should be a cleaner way to do this. ;; (%vertex-array% (append (flatten-lines (the %lines-to-draw%)) (flatten-curves (the %curves-to-draw%)))) (%lines-to-draw% (if (or (the display-tessellation-lines-wireframe?) (member (the isos) '(:tess :tessellation))) (the tessellation-lines) (if (the isos) (append-elements (the faces) (the-element %lines-to-draw%)) (append-elements (the edges) (the-element %lines-to-draw%))))) ;; ;; FLAG -- conditionalize all this based on :display-controls and :isos. ;; (%curves-to-draw% (cond ((null (the isos)) (when *debug?* (format *trace-output* "Processing edges for ~s.~%" (cons 'the (reverse (the root-path))))) (append-elements (the edges) (the-element %curves-to-draw%))) ((member (the isos) '(:tess :tessellation)) nil) (t (append-elements (the faces) (the-element %curves-to-draw%))))) (tessellation-lines (let ((faces (the %tess-data%))) (mapcan #'(lambda(face) (destructuring-bind (vertex-counts vertex-indices 3d-points surface-normals) face (declare (ignore vertex-counts surface-normals)) (let ((3d-points (coerce 3d-points 'vector)) (index-triplets (make-triplets vertex-indices))) (mapcan #'(lambda(triplet) (list (list (apply-make-point (svref 3d-points (first triplet))) (apply-make-point (svref 3d-points (second triplet)))) (list (apply-make-point (svref 3d-points (second triplet))) (apply-make-point (svref 3d-points (third triplet)))) (list (apply-make-point (svref 3d-points (third triplet))) (apply-make-point (svref 3d-points (first triplet)))))) index-triplets)))) faces))) ;; ;; FLAG -- review this! ;; (local-box (the bounding-box)) (%native-faces% (get-faces-from-brep *geometry-kernel* (the %native-brep%))) (%native-edges% (get-edges-from-brep *geometry-kernel* (the %native-brep%))) (%native-regions% (get-regions-from-brep *geometry-kernel* (the %native-brep%))) (%native-shells% (get-shells-from-brep *geometry-kernel* (the %native-brep%))) (%native-vertices% (get-vertices-from-brep *geometry-kernel* (the %native-brep%))) (faces-ht (let ((ht (make-hash-table :size (the faces number-of-elements)))) (dolist (face (list-elements (the faces)) ht) (setf (gethash (the-object face %native-face%) ht) face)))) ) :objects () :hidden-objects ( (bounding-box-solid :type 'box-solid :center (the bounding-bbox center) :width (the bounding-bbox width) :length (the bounding-bbox length) :height (the bounding-bbox height)) (face-points :type 'point :sequence (:size (the bounding-box-solid face-breps number-of-elements)) :center (the (brep-solve (the bounding-box-solid (face-breps (the-child index))) :minimize))) ("Sequence of GDL Brep objects. One brep for each face in the parent brep, containing only that face." face-breps :type 'facial-brep :sequence (:size (the faces number-of-elements)) :display-controls (append (list :color (nth (mod (the-child index) (length (the face-brep-colors))) (the face-brep-colors))) (the display-controls)) :%source-native-brep% (the %native-brep%) :%native-face% (the (faces (the-child index)) %native-face%)) ("Sequence of GDL Face Objects. The Faces contained within this brep." faces :type 'face ;;:hidden? (the hide-faces?) :sequence (:size (length (the %native-faces%))) :brep self :layer (the-child index) :pseudo-inputs (layer) :%native-brep% (the %native-brep%) :%native-face% (nth (the-child index) (the %native-faces%))) (face-triangles :type 'face-triangles :sequence (:size (length (getf (the %triangle-data%) :vertex-index-counts))) :triangle-data-in (the %triangle-data%)) ("Sequence of GDL Region Objects. The Regions contained within this brep." regions :type 'region :sequence (:size (length (the %native-regions%))) :brep self :%native-brep% (the %native-brep%) :%native-region% (nth (the-child index) (the %native-regions%))) ("Sequence of GDL Shell Objects. The Shells contained within this brep." shells :type 'brep-shell :sequence (:size (length (the %native-shells%))) :brep self :%native-brep% (the %native-brep%) :%native-shell% (nth (the-child index) (the %native-shells%))) ("Sequence of GDL Edge Objects. The Edges contained within this brep." edges :type 'edge :sequence (:size (length (the %native-edges%))) :brep self :%native-brep% (the %native-brep%) :%native-edge% (nth (the-child index) (the %native-edges%))) ("The composed edges contained within this brep, this is valid just if the brep does not contain holes" composed-edges :type 'composed-curve :curves (list-elements (the edges ))) ("Sequence of GDL Edge Objects. The Edges contained within this brep aranged clockwise or anticlockwise, this is valid just if the brep does not contain holes" edges-sequence :type 'subdivided-curve :continuity-type :c0 :curve-in (the composed-edges)) ("Sequence of GDL Vertex Objects. The Vertices contained within this brep." vertices :type 'vertex :sequence (:size (length (the %native-vertices%))) :brep self :%native-brep% (the %native-brep%) :%native-vertex% (nth (the-child index) (the %native-vertices%))) ("Polygonal Brep Object. This brep represented as a Polygonal Brep" poly-brep :type 'poly-brep :brep self :max-chord-height (the max-chord-height) :max-angle-degrees (the max-angle-degrees) :max-3d-edge (the max-3d-edge) :max-aspect-ratio (the max-aspect-ratio) :smooth-results? (the poly-brep-smooth-results?))) :functions ( ("Value nil or t. This function performs an intersection between this brep and another brep. The function returns a NIL value if no intersection is found and T if a intersection is found. :arguments (other-brep \"GDL Brep. The brep with which to intersect.\") :&key ((tolerance (the adaptive-tolerance)) \"Number, Controls how precisely the intersection is computed.\" (angle-tolerance (radians-to-degrees *angle-tolerance-radians-default*)) \"Number, in radians. The angle tolerance for intersection.\")" brep-intersect? (other-brep &key (tolerance (the adaptive-tolerance)) (angle-tolerance (radians-to-degrees *angle-tolerance-radians-default*))) (when (the (bbox-intersect? other-brep)) (brep-intersect? *geometry-kernel* (the %native-brep%) (the-object other-brep %native-brep%) :tolerance tolerance :angle-tolerance angle-tolerance))) (bbox-intersect? (brep) (block func (let ((my-min (first (the bounding-box))) (my-max (second (the bounding-box))) (his-min (first (the-object brep bounding-box))) (his-max (second (the-object brep bounding-box)))) (when (not (and (< (get-x his-min) (get-x my-max)) (> (get-x his-max) (get-x my-min)))) (return-from func nil)) (when (not (and (< (get-y his-min) (get-y my-max)) (> (get-y his-max) (get-y my-min)))) (return-from func nil)) (when (not (and (< (get-z his-min) (get-z my-max)) (> (get-z his-max) (get-z my-min)))) (return-from func nil)) (return-from func t)))) (brep-solve (brep operation) (global-brep-brep-solve *geometry-kernel* self :other-brep brep :operation-type operation)) (assert-valid () (brep-assert-valid *geometry-kernel* (the %native-brep%))) (write-stl-file (file-name &key (format :ascii)) (the poly-brep (write-stl-file file-name :format format))) ("Plist or list. Contains tessellation data for the brep based on the values of the keyword args. This is used to produce the value of (the triangle-data). :&key ((min-number-of-segments (the min-number-of-segments)) \"\" (max-3d-edge (the max-3d-edge)) \"\" (min-parametric-ratio (the min-parametric-ratio)) \"\" (max-chord-height (the max-chord-height)) \"\" (max-angle-degrees (the max-angle-degrees)) \"\" (min-3d-edge (the min-3d-edge)) \"\" (min-edge-ratio-uv (the min-edge-ratio-uv)) \"\" (max-aspect-ratio (the max-aspect-ratio)) \"\" (in-memory? t) \"\")" tessellation (&key (min-number-of-segments (the min-number-of-segments)) (max-3d-edge (the max-3d-edge)) (min-parametric-ratio (the min-parametric-ratio)) (max-chord-height (the max-chord-height)) (max-angle-degrees (the max-angle-degrees)) (min-3d-edge (the min-3d-edge)) (min-edge-ratio-uv (the min-edge-ratio-uv)) (max-aspect-ratio (the max-aspect-ratio)) (in-memory? t)) (let ((raw-data (get-triangles *geometry-kernel* (the %native-brep%) :min-number-of-segments min-number-of-segments :max-3d-edge max-3d-edge :min-parametric-ratio min-parametric-ratio :max-chord-height max-chord-height :max-angle-degrees max-angle-degrees :min-3d-edge min-3d-edge :min-edge-ratio-uv min-edge-ratio-uv :max-aspect-ratio max-aspect-ratio :in-memory? in-memory?))) raw-data)) ("Multiple values: Number, Number, Number, and Plist. Returns the area, volume, mass, and moments for the brep. The moments are labeled as: :area-static-moments, :area-moments-of-inertia, :area-products-of-inertia, :area-second-moment-about-coordinate-axii, :volume-static-moments, :volume-moments-of-inertia, :volume-products-of-inertia, and :volume-second-moment-about-coordinate-axii. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" precise-properties (&key (tolerance (the adaptive-tolerance))) (brep-compute-precise-properties *geometry-kernel* self tolerance)) ("Plist with keys: :area, :volume, :mass, :moments. Returns the area, volume, mass, and moments for the brep. The moments are labeled as: :area-static-moments, :area-moments-of-inertia, :area-products-of-inertia, :area-second-moment-about-coordinate-axii, :volume-static-moments, :volume-moments-of-inertia, :volume-products-of-inertia, and :volume-second-moment-about-coordinate-axii. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" precise-properties-plist (&key (tolerance (the adaptive-tolerance))) (multiple-value-bind (area volume mass moments) (brep-compute-precise-properties *geometry-kernel* self tolerance) (list :area area :volume volume :mass mass :moments moments))) ("Plist with keys: :area, :volume, :barycenter. Returns the approximate area, volume, and barycenter (center of mass) for the brep. These are computed with tessellation techniques, which may be less precise than the analytic techniques used in precise-properties, but should be faster to compute and exhibit more stability. :&key ((edge-tess-tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed with respect to edge tessellation\") ((face-tess-tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed with respect to face tessellation\")" properties (&key (edge-tess-tolerance (the adaptive-tolerance)) (face-tess-tolerance (the adaptive-tolerance))) (brep-compute-properties *geometry-kernel* self :edge-tess-tolerance edge-tess-tolerance :face-tess-tolerance face-tess-tolerance)) ("Number. Area covered by the faces of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" area (&key (tolerance (the adaptive-tolerance))) (multiple-value-bind (area volume mass moments) (the (precise-properties :tolerance tolerance)) (declare (ignore volume mass moments)) area)) ("Number. Volume enclosed by the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" volume (&key (tolerance (the adaptive-tolerance))) (multiple-value-bind (area volume mass moments) (the (precise-properties :tolerance tolerance)) (declare (ignore area mass moments)) volume)) ("Number. Mass represented by the brep, according to the density. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" mass (&key (tolerance (the adaptive-tolerance))) (multiple-value-bind (area volume mass moments) (the (precise-properties :tolerance tolerance)) (declare (ignore area volume moments)) (* (the density) mass))) ("Boolean. Returns t or nil depending on whether the point given is within the boundary of the brep (including faces). :arguments (point \"Point to check for\")" in? (point) (in? *geometry-kernel* self point)) ("Plist. Returns the moments of the brep. The plist contains keys: :area-static-moments, :area-moments-of-inertia, :area-products-of-inertia, :area-second-moment-about-coordinate-axii, :volume-static-moments, :volume-moments-of-inertia, :volume-products-of-inertia, and :volume-second-moment-about-coordinate-axii. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" moments (&key (tolerance (the adaptive-tolerance))) (multiple-value-bind (area volume mass moments) (the (precise-properties :tolerance tolerance)) (declare (ignore area volume mass)) moments)) ("3D Vector (i.e. 3D Point). Returns the Area Static Moments of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" area-static-moments (&key (tolerance (the adaptive-tolerance))) (getf (the (moments :tolerance tolerance)) :area-static-moments)) ("3D Vector (i.e. 3D Point). Returns the Area Moments of Inertia of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" area-moments-of-inertia (&key (tolerance (the adaptive-tolerance))) (getf (the (moments :tolerance tolerance)) :area-moments-of-inertia)) ("3D Vector (i.e. 3D Point). Returns the Area Products of Inertia of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" area-products-of-inertia (&key (tolerance (the adaptive-tolerance))) (getf (the (moments :tolerance tolerance)) :area-products-of-inertia)) ("3D Vector (i.e. 3D Point). Returns the Area Second Moment About Coordinate Axii of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" area-second-moment-about-coordinate-axii (&key (tolerance (the adaptive-tolerance))) (getf (the (moments :tolerance tolerance)) :area-second-moment-about-coordinate-axii)) ("3D Vector (i.e. 3D Point). Returns the Volume Static Moments of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" volume-static-moments (&key (tolerance (the adaptive-tolerance))) (getf (the (moments :tolerance tolerance)) :volume-static-moments)) ("3D Vector (i.e. 3D Point). Returns the Volume Moments of Inertia of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" volume-moments-of-inertia (&key (tolerance (the adaptive-tolerance))) (getf (the (moments :tolerance tolerance)) :volume-moments-of-inertia)) ("3D Vector (i.e. 3D Point). Returns the Volume Products of Inertia of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" volume-products-of-inertia (&key (tolerance (the adaptive-tolerance))) (getf (the (moments :tolerance tolerance)) :volume-products-of-inertia)) ("3D Vector (i.e. 3D Point). Returns the Volume Second Moment about Coordinate Axii of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" volume-second-moment-about-coordinate-axii (&key (tolerance (the adaptive-tolerance))) (getf (the (moments :tolerance tolerance)) :volume-second-moment-about-coordinate-axii)) ("3D Point. Center of gravity of the mass of the brep. :&key ((tolerance (the adaptive-tolerance)) \"Controls how precisely the properties are computed\")" center-of-gravity (&key (tolerance (the adaptive-tolerance))) (let ((volume (the volume :tolerance tolerance))) (when (zerop volume) (error "~a is a zero-volume brep. Center-of-gravity cannot be computed.~%" (cons 'the (reverse (the root-path))))) (scalar*vector (/ volume) (getf (the (moments :tolerance tolerance)) :volume-static-moments)))))) ;; ;; FLAG -- need glisp:split-regexp definition for these next two. ;; #+nil (defun read-stl-file (&key (file-name "/tmp/try.stl")) (let (result) (with-open-file (in file-name) (read-line in) (do ((facet-normal (read-line in) (read-line in))) ((search "endsolid" facet-normal) (nreverse result)) (let ((outer-loop (read-line in)) (v1 (read-line in)) (v2 (read-line in)) (v3 (read-line in)) (endloop (read-line in)) (endfacet (read-line in))) (declare (ignore outer-loop endloop endfacet)) (push (list :facet-normal (point-from-line facet-normal 2) :v1 (point-from-line v1) :v2 (point-from-line v2) :v3 (point-from-line v3)) result)))))) #+nil (defun point-from-line (line &optional (words 1)) (let ((list (subseq (glisp:split-regexp "\\s" (string-trim (list #\space) line)) words))) (destructuring-bind (x y z) list (make-point (read-from-string x) (read-from-string y) (read-from-string z))))) (define-object face-triangles () :input-slots (triangle-data-in) :computed-slots ((vertex-count-count (svref (getf (the triangle-data-in) :vertex-count-counts) (the index))) (vertex-index-count (svref (getf (the triangle-data-in) :vertex-index-counts) (the index))) (face-vertex-count (svref (getf (the triangle-data-in) :face-vertex-counts) (the index))) (cum-vertex-count-count (if (the first?) (the vertex-count-count) (+ (the vertex-count-count) (the previous cum-vertex-count-count)))) (cum-vertex-index-count (if (the first?) (the vertex-index-count) (+ (the vertex-index-count) (the previous cum-vertex-index-count)))) (cum-face-vertex-count (if (the first?) (the face-vertex-count) (+ (the face-vertex-count) (the previous cum-face-vertex-count)))) (vertex-counts (subseq (getf (the triangle-data-in) :vertex-counts) (- (the cum-vertex-count-count) (the vertex-count-count)) (the cum-vertex-count-count))) (full-vertex-indices (map 'vector #'(lambda(index) (+ index (- (the cum-face-vertex-count) (the face-vertex-count)))) (the vertex-indices))) (vertex-indices (subseq (getf (the triangle-data-in) :vertex-indices) (- (the cum-vertex-index-count) (the vertex-index-count)) (the cum-vertex-index-count))) (3d-points (subseq (getf (the triangle-data-in) :3d-points) (- (the cum-face-vertex-count) (the face-vertex-count)) (the cum-face-vertex-count))) (surface-normals (subseq (getf (the triangle-data-in) :surface-normals) (- (the cum-face-vertex-count) (the face-vertex-count)) (the cum-face-vertex-count))) (uv-points (subseq (getf (the triangle-data-in) :uv-points) (- (the cum-face-vertex-count) (the face-vertex-count)) (the cum-face-vertex-count))) (triangle-data (list :vertex-counts (the vertex-counts) :vertex-indices (the vertex-indices) :3d-points (the 3d-points) :uv-points (the uv-points) :surface-normals (the surface-normals) )))) ;; ;; VRML/x3D parameter test development ;; #+nil (define-object test-b-spline-surface (b-spline-surface) :input-slots ((display-controls (list :color :periwinkle ;;:line-thickness 2 ))) :computed-slots ((points-data '(((0 0 0)(4 1 0)(8 1 0)(10 0 0)(8 -1 0)(4 -1 0)(0 0 0)) ((0 0 2) (4 2 2) (8 2 2) (10 0 2) (8 -2 2) (4 -2 2) (0 0 2)) ((0 0 4) (4 2 4) (8 2 4) (10 0 4) (8 -2 4) (4 -2 4) (0 0 4)) ((0 0 7) (4 1 7) (8 1 7) (10 0 7) (8 -1 7) (4 -1 7) (0 0 7)))) (control-points (mapcar #'(lambda(list) (mapcar #'apply-make-point list)) (the points-data)))) :hidden-objects ((view :type 'base-view :projection-vector (getf *standard-views* :trimetric) :page-width (* 5 72) :page-length (* 5 72) :objects (list self)))) #+nil (define-object scaled-b-spline (base-object) :input-slots ((scale-factor 1 :settable)) :objects ((surface :type 'test-b-spline-surface) (scaled :type 'boxed-surface :surface-in (the surface) :scale (the scale-factor)) (brep :type 'brep :max-chord-height (* (the-child max-extent) 0.0005) :%native-brep% (the scaled brep %native-brep%))))
37,529
Common Lisp
.lisp
647
43.715611
148
0.589762
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
6e10e273cd51cbc00042bac1c7d695002ae71d6fe405aac7afc9a7f8351700eb
35,860
[ -1 ]
35,861
extended-surface.lisp
lisp-mirror_gendl/surf/source/extended-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object extended-surface (surface) :documentation (:description "Extends a surface to a curve, so that curve will become one of the new boundaries for the surface. Continuity is controlled via options. Note that in the example, extended and extended-2 do not give a smooth transition to the extended part of the surface because the original surface is only degree 1 in the direction of extension." :examples " <pre> (in-package :gdl-user) (define-object extended-surface-test (base-object) :computed-slots ((regression-test-data (list (multiple-value-list (the extended b-spline-data)) (multiple-value-list (the extended-2 b-spline-data)) (multiple-value-list (the extended-3 b-spline-data)) (multiple-value-list (the extended-4 b-spline-data)))) (display-list-objects (list (the loft) (the extended) (the extended-2)))) :objects ((test3 :type 'linear-curve :start (make-point 0 0 0) :end (make-point 10 0 0)) (test4 :type 'linear-curve :start (make-point 0 10 0) :end (make-point 10 10 0)) (mid-1 :type 'linear-curve :start (make-point 0 5.0 1) :end (make-point 10 5.0 1)) (mid-2 :type 'linear-curve :start (make-point 0 8.0 1) :end (make-point 10 8.0 1)) (bridge-1 :type 'b-spline-curve :control-points (list (make-point 0 0 0) (make-point -2 5.0 3) (make-point -2 8.0 3) (make-point 0 10 0))) (bridge-2 :type 'b-spline-curve :control-points (list (make-point 10 0 0) (make-point 12 5.0 5) (make-point 12 8.0 5) (make-point 10 10 0))) (bridge-3 :type 'b-spline-curve :control-points (list (make-point 0 -1 0) (make-point 3 -1 5) (make-point 7 -1 5) (make-point 10 -1 0))) (loft :type 'lofted-surface :curves (list (the test3) (the mid-1) (the mid-2) (the test4))) (extended :type 'extended-surface :display-controls (list :color :red :line-thickness 2) :surface (the loft) :curve (the bridge-1) :direction :v :which-end :start) (extended-2 :type 'extended-surface :display-controls (list :color :green :line-thickness 2) :surface (the loft) :curve (the bridge-1) :direction :v :which-end :start :deformation-param (+ (* 0.25 (- (the-child surface v-max) (the-child surface v-min))) (the-child surface u-min))) (extended-3 :type 'extended-surface :display-controls (list :color :orange :isos (list :n-u 25 :n-v 25)) :surface (the loft) :curve (the bridge-3) :direction :u :continuity :cmax :which-end :start) (extended-4 :type 'extended-surface :display-controls (list :color :blue :isos (list :n-u 25 :n-v 25)) :surface (the loft) :curve (the bridge-3) :direction :u :deformation-param (+ (* 0.25 (- (the-child surface u-max) (the-child surface u-min))) (the-child surface u-min)) :continuity :cmax :which-end :start))) (generate-sample-drawing :objects (the-object (make-object 'extended-surface-test) display-list-objects) :projection-direction (getf *standard-views* :trimetric)) </pre>") :input-slots ("GDL surface object. The surface to be extended." surface "GDL curve object. The curve to which the surface should be extended." curve ("Keyword symbol, one of :start or :end. Default is :start." which-end :start) ("Keyword symbol, if deformation-param is given this can be one of :c1, :c2, or :cmax, and if deformation-param is not given this can be one of :g1 or :cmax. Default is :c1 if deformation-param is given and :g1 if deformation-param is not given." continuity (if (the deformation-param) :c1 :g1)) ("Keyword symbol, one of :u or :v. The direction of extension. Note that if deformation-param is given, it will be a U parameter if this input :u, and a V parameter if this input is :v. Default is :u." direction :u) ("Number, either a U or a V surface parameter. This value, if given, controls how far inward from the affected boundary the surface is modified. If (the direction) is :u, then this will be a U parameter, and likewise if (the direction) is :v, then this will be a V parameter. Default is nil which indicates no specific control over any deformation." deformation-param nil)) :computed-slots ((native-surface (make-extended-surface *geometry-kernel* :surface (the surface native-surface) :direction (the direction) :curve (the curve native-curve) :direction (the direction) :which-end (the which-end) :continuity (if (the deformation-param) (ecase (the continuity) (:c1 1) (:c2 5) (:cmax 4)) (ecase (the continuity) (:g1 2) (:cmax 4))) :deformation-param (the deformation-param)))))
7,301
Common Lisp
.lisp
147
34.22449
87
0.5451
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
0d1899c9aa69c38b39536ffe220ee832590125a75d01ca2d1fd2259772b84317
35,861
[ -1 ]
35,862
classes.lisp
lisp-mirror_gendl/surf/source/classes.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (defclass vanilla-geometry-kernel ()())
928
Common Lisp
.lisp
22
39.681818
71
0.741111
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
fe773bf59b725e45f9a40321d731b5485e30ff39b45673a26ed1990d9b411610
35,862
[ -1 ]
35,863
fitted-conic.lisp
lisp-mirror_gendl/surf/source/fitted-conic.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object fitted-conic (curve) :input-slots (points (parameterization :chordlength) (tangency :bessel) (smooth-corners? t)) :computed-slots ((native-curve (interpolate-conic *geometry-kernel* :points (the points) :parameterization (the parameterization) :tangency (the tangency) :smooth-corners? (the smooth-corners?)))))
1,401
Common Lisp
.lisp
33
34.818182
79
0.659496
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
5fa887c89e2d0ad33f4f02a090b850055a12031d63d7d296e7ae915151c46f3b
35,863
[ -1 ]
35,864
methods.lisp
lisp-mirror_gendl/surf/source/methods.lisp
;; ;; Copyright 2002-2011, 2012 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (defmacro define-vanilla-wrapper (name (&rest args)) `(defmethod ,name ((geometry-kernel vanilla-geometry-kernel) ,@args) (declare (ignore ,@(remove '&key args))) (error "Don't know how to do ~a using ~s.~%" ',name geometry-kernel))) (defun make-uniform-knot-vector (cpoint-length degree) (let* ((knot-vector-length (+ cpoint-length degree 1)) (clamp-length (1+ degree)) (internal-length (- knot-vector-length (twice clamp-length)))) (when (minusp internal-length) (error "Cannot make knot vector with ~a points and degree ~a.~%" cpoint-length degree)) (append (make-list clamp-length :initial-element 0.0) (let ((increment (/ (1+ internal-length))) result) (dotimes (i internal-length (nreverse result)) (push (* (1+ i) increment) result))) (make-list clamp-length :initial-element 1.0)))) (defmethod make-geometry-kernel ((type t) &key (in-memory t) (host nil) (login nil) (password nil)) (declare (ignore in-memory host login password)) (error "Don't know about geometry kernel type `~s'. Please try (require ~(~s~)).~%" type type)) (defmethod make-geometry-kernel ((type (eql :vanilla)) &key (in-memory t) (host nil) (login nil) (password nil)) (declare (ignore in-memory host login password)) (format t "~&Setting surf:*geometry-kernel* to the Vanilla (i.e. skeleton) geometry kernel.~%") (setq *geometry-kernel* (make-instance 'vanilla-geometry-kernel))) (defmethod decomposed-curves ((geometry-kernel vanilla-geometry-kernel) native-curve) (declare (ignore native-curve)) (error "Don't know how to decompose nurbs using ~s.~%" geometry-kernel)) (defmethod nurbs-to-beziers ((geometry-kernel vanilla-geometry-kernel) native-curve tolerance degree parameterization maintain-end-tangents? container rational? &key control-points-only?) (declare (ignore native-curve tolerance degree parameterization maintain-end-tangents? container rational? control-points-only?)) (error "Don't know how to convert nurbs to beziers using ~s.~%" geometry-kernel)) (defmethod make-arc-curve ((geometry-kernel vanilla-geometry-kernel) center orientation radius start-angle end-angle) (declare (ignore center orientation radius start-angle end-angle)) (error "Don't know how to make an arc curve using ~s.~%" geometry-kernel)) (defmethod make-elliptical-curve ((geometry-kernel vanilla-geometry-kernel) center orientation minor-axis-length major-axis-length start-angle end-angle) (declare (ignore center orientation minor-axis-length major-axis-length start-angle end-angle)) (error "Don't know how to make an ellipse curve using ~s.~%" geometry-kernel)) (defmethod get-curve-control-points ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to get control points from curve using ~s.~%" geometry-kernel)) (defmethod is-curve-rational ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to check for rationality of curve using ~s.~%" geometry-kernel)) (defmethod get-curve-parameter-bounds ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to get parameter bounds from curve using ~s.~%" geometry-kernel)) (defmethod curve-on-plane? ((geometry-kernel vanilla-geometry-kernel) curve plane-point plane-normal &key distance-tolerance) (declare (ignore curve plane-point plane-normal distance-tolerance)) (error "Don't know how to detect curve on plane using ~s.~%" geometry-kernel)) (defmethod get-curve-dropped-point ((geometry-kernel vanilla-geometry-kernel) curve 3d-point &key distance-tolerance) (declare (ignore curve 3d-point distance-tolerance)) (error "Don't know how to get dropped point from curve using ~s.~%" geometry-kernel)) (defmethod get-curve-minimum-radius ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to get minimum radius of curve using ~s.~%" geometry-kernel)) (defmethod get-offset-point-along ((geometry-kernel vanilla-geometry-kernel) curve parameter distance) (declare (ignore curve parameter distance)) (error "Don't know how to offset point along curve using ~s.~%" geometry-kernel)) (defmethod get-surface-curve-intersection-points ((geometry-kernel vanilla-geometry-kernel) surface curve &key 3d-tolerance) (declare (ignore surface curve 3d-tolerance)) (error "Don't know how to do surface-curve intersection using ~s.~%" geometry-kernel)) (defmethod get-curve-plane-intersection-point ((geometry-kernel vanilla-geometry-kernel) curve plane-point plane-normal) (declare (ignore curve plane-point plane-normal)) (error "don't know how to get plane intersection point for curve using ~s.~%" geometry-kernel)) (defmethod get-curve-curve-intersection-point ((geometry-kernel vanilla-geometry-kernel) curve other-curve &key distance-tolerance) (declare (ignore curve other-curve distance-tolerance)) (error "don't know how to get curve intersection point for curve using ~s.~%" geometry-kernel)) (defmethod global-curve-solve ((geometry-kernel vanilla-geometry-kernel) curve &key other-curve operation-type) (declare (ignore curve other-curve operation-type)) (error "don't know how to do global curve solution using ~s.~%" geometry-kernel)) (defmethod global-surface-curve-solve ((geometry-kernel vanilla-geometry-kernel) surface &key curve operation-type) (declare (ignore surface curve operation-type)) (error "don't know how to do global surface curve solution using ~s.~%" geometry-kernel)) (defmethod global-surface-surface-solve ((geometry-kernel vanilla-geometry-kernel) surface &key other-surface operation-type) (declare (ignore surface other-surface operation-type)) (error "don't know how to do global surface surface solution using ~s.~%" geometry-kernel)) (defmethod surface-evaluate-geometric ((geometry-kernel vanilla-geometry-kernel) surface u v) (declare (ignore surface u v)) (error "don't know how to do geometric evaluation of surface point using ~s.~%" geometry-kernel)) (defmethod surface-global-line-intersect ((geometry-kernel vanilla-geometry-kernel) surface point vector &key distance-tolerance) (declare (ignore surface point vector distance-tolerance)) (error "don't know how to do surface global line intersect using ~s.~%" geometry-kernel)) (defmethod surface-get-domain-components ((geometry-kernel vanilla-geometry-kernel) surface) (declare (ignore surface)) (error "don't know how to get surface domain components using ~s.~%" geometry-kernel)) (defmethod global-curve-point-solve ((geometry-kernel vanilla-geometry-kernel) curve &key point operation-type) (declare (ignore curve point operation-type)) (error "don't know how to do global curve-point solution using ~s.~%" geometry-kernel)) (defmethod make-b-spline-curve ((geometry-kernel vanilla-geometry-kernel) control-points weights degree knot-vector) (declare (ignore control-points weights degree knot-vector)) (error "Don't know how to make b-spline-curve using ~s.~%" geometry-kernel)) (define-vanilla-wrapper make-offset-curve (&key curve plane-normal offset-distance tolerance)) (defmethod get-curve-b-spline-data ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to get curve b-spline-data using ~s.~%" geometry-kernel)) (defmethod get-surface-b-spline-data ((geometry-kernel vanilla-geometry-kernel) surface) (declare (ignore surface)) (error "Don't know how to get surface b-spline-data using ~s.~%" geometry-kernel)) (defmethod get-point-at-arc-length ((geometry-kernel vanilla-geometry-kernel) curve percentage &key tolerance) (declare (ignore curve percentage tolerance)) (error "Don't know how to get point at arc-length using ~s.~%" geometry-kernel)) (defmethod %get-point-on-curve ((geometry-kernel vanilla-geometry-kernel) curve parameter) (declare (ignore curve parameter)) (error "Don't know how to get point on curve using ~s.~%" geometry-kernel)) (defmethod get-curve-tangent ((geometry-kernel vanilla-geometry-kernel) curve parameter) (declare (ignore curve parameter)) (error "Don't know how to get curve tangent using ~s.~%" geometry-kernel)) (defmethod get-curve-curvature ((geometry-kernel vanilla-geometry-kernel) curve parameter) (declare (ignore curve parameter)) (error "Don't know how to get curve curvature info using ~s.~%" geometry-kernel)) (defmethod get-curve-total-length ((geometry-kernel vanilla-geometry-kernel) curve u1 u2 tolerance tolerance-type) (declare (ignore curve u1 u2 tolerance tolerance-type)) (error "Don't know how to get curve length using ~s.~%" geometry-kernel)) (defmethod get-curve-first-derivative ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to get first derivative of curve using ~s.~%" geometry-kernel)) (defmethod get-curve-second-derivative ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to get second derivative of curve using ~s.~%" geometry-kernel)) (defmethod get-surface-control-points ((geometry-kernel vanilla-geometry-kernel) surface) (declare (ignore surface)) (error "Don't know how to get control points from surface using ~s.~%" geometry-kernel)) (defmethod make-b-spline-surface ((geometry-kernel vanilla-geometry-kernel) control-points weights u-degree u-knot-vector v-degree v-knot-vector) (declare (ignore control-points weights u-degree u-knot-vector v-degree v-knot-vector)) (error "Don't know how to make b-spline-surface using ~s.~%" geometry-kernel)) (defmethod get-iso-curves ((geometry-kernel vanilla-geometry-kernel) surface direction number) (declare (ignore surface direction number)) (error "Don't know how to get iso curves using ~s.~%" geometry-kernel)) (defmethod %get-point-on-surface ((geometry-kernel vanilla-geometry-kernel) surface u v) (declare (ignore surface u v)) (error "Don't know how to get point on surface using ~s.~%" geometry-kernel)) (defmethod get-surface-normal ((geometry-kernel vanilla-geometry-kernel) surface u v) (declare (ignore surface u v)) (error "Don't know how to get surface normal using ~s.~%" geometry-kernel)) (defmethod interpolate-curve ((geometry-kernel vanilla-geometry-kernel) points degree parameterization &key vectors vector-type interpolant? tolerance) (declare (ignore points degree parameterization vectors vector-type interpolant? tolerance)) (error "Dont know how to interpolate curve using ~s.~%" geometry-kernel)) (defmethod interpolate-surface ((geometry-kernel vanilla-geometry-kernel) points u-degree v-degree parameterization) (declare (ignore points u-degree v-degree parameterization)) (error "Dont know how to interpolate surface using ~s.~%" geometry-kernel)) (defmethod make-linear-curve ((geometry-kernel vanilla-geometry-kernel) start end) (declare (ignore start end)) (error "Don't know how to make a linear curve using ~s.~%" geometry-kernel)) (defmethod make-spherical-surface ((geometry-kernel vanilla-geometry-kernel) center radius start-sweep end-sweep profile-angle profile-degree revolution-degree) (declare (ignore center radius start-sweep end-sweep profile-angle profile-degree revolution-degree)) (error "Don't know how to make a spherical surface using ~s.~%" geometry-kernel)) (defmethod make-revolved-surface ((geometry-kernel vanilla-geometry-kernel) &key curve axis-point axis-vector arc flag) (declare (ignore curve axis-point axis-vector arc flag)) (error "Don't know how to make a revolved surface using ~s.~%" geometry-kernel)) (defmethod make-planar-surface ((geometry-kernel vanilla-geometry-kernel) p00 p01 p10 p11) (declare (ignore p00 p01 p10 p11)) (error "Don't know how to make a planar surface using ~s.~%" geometry-kernel)) ;; HWLibs methods (defmethod write-iges-file ((geometry-kernel vanilla-geometry-kernel) pathname &key points curves surfaces tolerance) (declare (ignore pathname points curves surfaces tolerance)) (error "Don't know how to write iges file using ~s.~%" geometry-kernel)) (defmethod write-iges-file* ((geometry-kernel vanilla-geometry-kernel) pathname &key points curves surfaces trimmed-surfaces solids quiet? units units-scale tolerance write-analytic-curves?) (declare (ignore pathname points curves surfaces trimmed-surfaces solids quiet? units units-scale tolerance write-analytic-curves?)) (error "Don't know how to write iges file using ~s.~%" geometry-kernel)) (defmethod read-iges-file ((geometry-kernel vanilla-geometry-kernel) pathname) (declare (ignore pathname)) (error "Don't know how to read iges file using ~s.~%" geometry-kernel)) (defmethod read-iges-file* ((geometry-kernel vanilla-geometry-kernel) pathname &key quiet? finalize-on) (declare (ignore pathname quiet? finalize-on)) (error "Don't know how to read iges file using ~s.~%" geometry-kernel)) (defmethod write-step-file* ((geometry-kernel vanilla-geometry-kernel) pathname &key points curves surfaces trimmed-surfaces solids quiet? units units-scale tolerance write-analytic-curves?) (declare (ignore pathname points curves surfaces trimmed-surfaces solids quiet? units units-scale tolerance write-analytic-curves?)) (error "Don't know how to write STEP file using ~s.~%" geometry-kernel)) (defmethod read-step-file* ((geometry-kernel vanilla-geometry-kernel) pathname &key quiet? finalize-on make-all-surfaces-trimmed? break-up-breps-into-trimmed-surfaces? group-trimmed-surfaces-into-brep? make-single-brep?) (declare (ignore pathname quiet? finalize-on make-all-surfaces-trimmed? break-up-breps-into-trimmed-surfaces? group-trimmed-surfaces-into-brep? make-single-brep?)) (error "Don't know how to read STEP file using ~s.~%" geometry-kernel)) ;;SMLib methods (defmethod write-native-file ((geometry-kernel vanilla-geometry-kernel) file-name &key curves surfaces breps file-type quiet?) (declare (ignore file-name curves surfaces breps file-type quiet?)) (error "Don't know how to write native file using ~s.~%" geometry-kernel)) (defgeneric read-native-file (geometry-kernel file-name &key file-type quiet? sew-and-shrink-breps?)) (defmethod read-native-file ((geometry-kernel vanilla-geometry-kernel) file-name &key file-type quiet? sew-and-shrink-breps?) (declare (ignore file-name sew-and-shrink-breps? file-type quiet?)) (error "Don't know how to read native file using ~s.~%" geometry-kernel)) (defmethod poly-brep-write-to-stl-file ((geometry-kernel vanilla-geometry-kernel) poly-brep file-name format) (declare (ignore poly-brep file-name format)) (error "Don't know how to write STL file using ~s.~%" geometry-kernel)) (defmethod make-poly-brep ((geometry-kernel vanilla-geometry-kernel) brep &key dCHTol dCrvTessAngle dSrfTessAngle dMax3DEdge dMaxAspect bSmoothResults) (declare (ignore brep dCHTol dCrvTessAngle dSrfTessAngle dMax3DEdge dMaxAspect bSmoothResults)) (error "Don't know how to make poly-brep using ~s.~%" geometry-kernel)) (defmethod make-brep ((geometry-kernel vanilla-geometry-kernel) &key tolerance) (declare (ignore tolerance)) (error "Don't know how to make brep using ~s.~%" geometry-kernel)) (defmethod make-b-spline-curve*-2d ((geometry-kernel vanilla-geometry-kernel) b-spline-curve*) (declare (ignore b-spline-curve*)) (error "Don't know how to make b-spline-curve* using ~s.~%" geometry-kernel)) (defmethod make-b-spline-surface* ((geometry-kernel vanilla-geometry-kernel) b-spline-surface &key (schedule-finalization? t)) (declare (ignore b-spline-surface schedule-finalization?)) (error "Don't know how to make b-spline-surface* using ~s.~%" geometry-kernel)) (defmethod make-b-spline-curve* ((geometry-kernel vanilla-geometry-kernel) b-spline-curve &key (schedule-finalization? t)) (declare (ignore b-spline-curve schedule-finalization?)) (error "Don't know how to make b-spline-curve* using ~s.~%" geometry-kernel)) (defmethod make-trimmed-face ((geometry-kernel vanilla-geometry-kernel) brep loops-3d loops-uv orientations loop-points basis* basis-orientation) (declare (ignore brep loops-3d loops-uv orientations loop-points basis* basis-orientation)) (error "Don't know how to make trimmed face using ~s.~%" geometry-kernel)) (defmethod make-trimmed-iso-curves ((geometry-kernel vanilla-geometry-kernel) face tolerance curves-3d curves-uv) (declare (ignore face tolerance curves-3d curves-uv)) (error "Don't know how to make trimmed isos using ~s.~%" geometry-kernel)) (defmethod make-face-boundary-curves ((geometry-kernel vanilla-geometry-kernel) face) (declare (ignore face)) (error "Don't know how to make face boundary using ~s.~%" geometry-kernel)) (defmethod get-b-spline-curve*-data ((geometry-kernel vanilla-geometry-kernel) b-spline-curve*) (declare (ignore b-spline-curve*)) (error "Don't know how to get curve* data using ~s.~%" geometry-kernel)) (defmethod drop-curve ((geometry-kernel vanilla-geometry-kernel) curve-in surface) (declare (ignore curve-in surface)) (error "Don't know how to drop curve using ~s.~%" geometry-kernel)) (define-vanilla-wrapper project-curve (curve-in surface projection-vector approximation-tolerance angle-tolerance)) (defmethod curve-convert-uv-to-3d ((geometry-kernel vanilla-geometry-kernel) curve-uv surface) (declare (ignore curve-uv surface)) (error "Don't know how to convert uv-curve to 3d-curve using ~s.~%" geometry-kernel)) (defmethod face-compute-precise-properties ((geometry-kernel vanilla-geometry-kernel) face desired-accuracy origin estimated-area face-thickness) (declare (ignore face desired-accuracy origin estimated-area face-thickness)) (error "Don't know how to compute precise properties using ~s.~%" geometry-kernel)) (defmethod surface-area ((geometry-kernel vanilla-geometry-kernel) surface desired-accuracy) (declare (ignore surface desired-accuracy)) (error "Don't know how to compute surface area using ~s.~%" geometry-kernel)) (defmethod get-faces-from-brep ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get faces from brep using ~s.~%" geometry-kernel)) (defmethod get-edges-from-brep ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get edges from brep using ~s.~%" geometry-kernel)) (defmethod get-bspline-curve-from-edge ((geometry-kernel vanilla-geometry-kernel) edge) (declare (ignore edge)) (error "Don't know how to get bspline-curve from edge using ~s.~%" geometry-kernel)) (defmethod get-uv-curve-from-edge ((geometry-kernel vanilla-geometry-kernel) edge surface) (declare (ignore edge surface)) (error "Don't know how to get bspline-curve from edge using ~s.~%" geometry-kernel)) (defmethod get-3d-point-from-vertex ((geometry-kernel vanilla-geometry-kernel) vertex) (declare (ignore vertex)) (error "Don't know how to get 3d-point from vertex using ~s.~%" geometry-kernel)) (defmethod get-regions-from-brep ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get regions from brep using ~s.~%" geometry-kernel)) (defmethod get-shells-from-brep ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get shells from brep using ~s.~%" geometry-kernel)) (defmethod get-shells-from-region ((geometry-kernel vanilla-geometry-kernel) region) (declare (ignore region)) (error "Don't know how to get shells from region using ~s.~%" geometry-kernel)) (defmethod get-vertices-from-brep ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get vertices from brep using ~s.~%" geometry-kernel)) (defmethod get-surface-from-face ((geometry-kernel vanilla-geometry-kernel) face) (declare (ignore face)) (error "Don't know how to get surface from face using ~s.~%" geometry-kernel)) (defmethod get-edges-from-face ((geometry-kernel vanilla-geometry-kernel) face) (declare (ignore face)) (error "Don't know how to get edges from face using ~s.~%" geometry-kernel)) (defmethod get-nurbs-from-surface ((geometry-kernel vanilla-geometry-kernel) surface) (declare (ignore surface)) (error "Don't know how to get nurbs from surface using ~s.~%" geometry-kernel)) (defmethod get-nurbs-from-curve ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to get nurbs from curve using ~s.~%" geometry-kernel)) (defmethod extract-face-hole-curves ((geometry-kernel vanilla-geometry-kernel) face) (declare (ignore face)) (error "Don't know how to extract face hole curves using ~s.~%" geometry-kernel)) (defmethod extract-face-island-curves ((geometry-kernel vanilla-geometry-kernel) face) (declare (ignore face)) (error "Don't know how to extract island hole curves using ~s.~%" geometry-kernel)) (defmethod u-min ((geometry-kernel vanilla-geometry-kernel) iw-surface) (declare (ignore iw-surface)) (error "Don't know how to get u-min from surface using ~s.~%" geometry-kernel)) (defmethod u-max ((geometry-kernel vanilla-geometry-kernel) iw-surface) (declare (ignore iw-surface)) (error "Don't know how to get u-max from surface using ~s.~%" geometry-kernel)) (defmethod v-min ((geometry-kernel vanilla-geometry-kernel) iw-surface) (declare (ignore iw-surface)) (error "Don't know how to get v-min from surface using ~s.~%" geometry-kernel)) (defmethod v-max ((geometry-kernel vanilla-geometry-kernel) iw-surface) (declare (ignore iw-surface)) (error "Don't know how to get v-max from surface using ~s.~%" geometry-kernel)) (defmethod set-long ((geometry-kernel vanilla-geometry-kernel) object value) (declare (ignore object value)) (error "Don't know how to set long attribute on object using ~s.~%" geometry-kernel)) (defmethod get-long ((geometry-kernel vanilla-geometry-kernel) object) (declare (ignore object)) (error "Don't know how to get long attribute from object using ~s.~%" geometry-kernel)) (defmethod get-levels ((geometry-kernel vanilla-geometry-kernel) object) (declare (ignore object)) (error "Don't know how to get levels from object using ~s.~%" geometry-kernel)) (defmethod get-color ((geometry-kernel vanilla-geometry-kernel) object) (declare (ignore object)) (error "Don't know how to get color from object using ~s.~%" geometry-kernel)) (defmethod add-box-primitive ((geometry-kernel vanilla-geometry-kernel) brep length width height x y z xx xy xz yx yy yz) (declare (ignore brep length width height x y z xx xy xz yx yy yz)) (error "Don't know how to add box primitive using ~s.~%" geometry-kernel)) (defmethod add-cone-primitive ((geometry-kernel vanilla-geometry-kernel) brep height base-radius top-radius start-angle end-angle x y z xx xy xz yx yy yz) (declare (ignore brep height base-radius top-radius start-angle end-angle x y z xx xy xz yx yy yz)) (error "Don't know how to add cone primitive using ~s.~%" geometry-kernel)) (defmethod add-linear-sweep-primitive ((geometry-kernel vanilla-geometry-kernel) brep curve-list axis-vector distance) (declare (ignore brep curve-list axis-vector distance)) (error "Don't know how to add linear-sweep primitive using ~s.~%" geometry-kernel)) (defmethod build-composites-from-curves ((geometry-kernel vanilla-geometry-kernel) curves &key (same-point-tolerance 0.01) (distance-to-create-line 0.1)) (declare (ignore curves same-point-tolerance distance-to-create-line)) (error "Don't know how to build composites from curves using ~s.~%" geometry-kernel)) (defmethod build-composite-curve ((geometry-kernel vanilla-geometry-kernel) curves) (declare (ignore curves)) (error "Don't know how to build composite curve using ~s.~%" geometry-kernel)) (defmethod intersect-surface-with-plane ((geometry-kernel vanilla-geometry-kernel) surface plane-normal plane-point &key 3d-approximation-tolerance angle-tolerance-radians) (declare (ignore surface plane-normal plane-point 3d-approximation-tolerance angle-tolerance-radians)) (error "Don't know how to intersect surface and plane using ~s.~%" geometry-kernel)) (defmethod iw-copy-curve ((geometry-kernel vanilla-geometry-kernel) iw-curve &key finalize?) (declare (ignore iw-curve finalize?)) (error "Don't know how to copy iw-curve using ~s.~%." geometry-kernel)) (defmethod iw-trim-curve ((geometry-kernel vanilla-geometry-kernel) iw-curve u1 u2) (declare (ignore iw-curve u1 u2)) (error "Don't know how to trim iw-curve using ~s.~%." geometry-kernel)) (defmethod curve-reverse ((geometry-kernel vanilla-geometry-kernel) curve) (declare (ignore curve)) (error "Don't know how to make reversed curve using ~s~%." geometry-kernel)) (defmethod bounding-box ((geometry-kernel vanilla-geometry-kernel) surface) (declare (ignore surface)) (error "Don't know how to get bounding box for surface using ~s~%." geometry-kernel)) (defmethod surface-drop-point ((geometry-kernel vanilla-geometry-kernel) surface poing &key 3d-tolerance) (declare (ignore surface poing 3d-tolerance)) (error "Don't know how to drop point on surface using ~s.~%" geometry-kernel)) (defmethod get-triangles ((geometry-kernel vanilla-geometry-kernel) brep &key minimum-number-of-segments maximum-3d-distance-between-points minimum-parametric-ratio chord-height angle-tolerance-degrees max-edge-length min-edge-length min-edge-length-ratio-uv max-aspect-ratio) (declare (ignore brep minimum-number-of-segments maximum-3d-distance-between-points minimum-parametric-ratio chord-height angle-tolerance-degrees max-edge-length min-edge-length min-edge-length-ratio-uv max-aspect-ratio)) (error "Don't know how to get triangles from brep ~s.~%" geometry-kernel)) (defmethod make-merge-container ((geometry-kernel vanilla-geometry-kernel) brep other-brep approximation-tolerance angle-tolerance) (declare (ignore brep other-brep approximation-tolerance angle-tolerance)) (error "Don't know how to make merge container using ~s.~%" geometry-kernel)) (defmethod do-boolean-merge-operation ((geometry-kernel vanilla-geometry-kernel) merge-container operation manifold? &key make-manifold?) (declare (ignore merge-container operation manifold? make-manifold?)) (error "Don't know how to do boolean merge operation with ~s.~%" geometry-kernel)) (defmethod do-boolean-separate-operation ((geometry-kernel vanilla-geometry-kernel) merge-container manifold? sew-and-orient?) (declare (ignore merge-container manifold? sew-and-orient?)) (error "Don't know how to do boolean separate operation with ~s.~%" geometry-kernel)) (defmethod make-linear-swept-brep ((geometry-kernel vanilla-geometry-kernel) facial-brep vector distance) (declare (ignore facial-brep vector distance)) (error "Don't know how to do linear swept brep with ~s.~%" geometry-kernel)) (defmethod in? ((geometry-kernel vanilla-geometry-kernel) brep point) (declare (ignore brep point)) (error "Don't know how to check for point in brep using ~s.~%" geometry-kernel)) (defmethod loft-surface ((geometry-kernel vanilla-geometry-kernel) curves &key stacks) (declare (ignore curves stacks)) (error "Don't know how to do lofted surface with ~s.~%" geometry-kernel)) (defmethod make-faces-from-surface ((geometry-kernel vanilla-geometry-kernel) brep surface &key continuity-type end-caps?) (declare (ignore brep surface continuity-type end-caps?)) (error "Don't know how to make faces from surface with ~s.~%" geometry-kernel)) (defmethod make-edge-from-curve ((geometry-kernel vanilla-geometry-kernel) brep curve) (declare (ignore brep curve)) (error "Don't know how to make edge from curve with ~s.~%" geometry-kernel)) (defmethod brep-get-wires ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get wires from brep with ~s.~%" geometry-kernel)) (defmethod brep-get-edges ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get edges from brep with ~s.~%" geometry-kernel)) (defmethod brep-copy ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to copy a brep with ~s.~%" geometry-kernel)) (defmethod brep-get-curves ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get curves from brep with ~s.~%" geometry-kernel)) (defmethod brep-get-my-curves ((geometry-kernel vanilla-geometry-kernel) brep) (declare (ignore brep)) (error "Don't know how to get curves from brep with ~s.~%" geometry-kernel)) (defmethod brep-compute-precise-properties ((geometry-kernel vanilla-geometry-kernel) brep tolerance) (declare (ignore brep tolerance)) (error "Don't know how to compute precise properties from brep with ~s.~%" geometry-kernel)) (define-vanilla-wrapper brep-compute-properties (brep &key edge-tess-tolerance face-tess-tolerance)) (defmethod make-blended-brep ((geometry-kernel vanilla-geometry-kernel) brep &key default-radius specs) (declare (ignore brep default-radius specs)) (error "Don't know how to make blended brep with ~s.~%" geometry-kernel)) (defmethod make-stitched-solid-brep ((geometry-kernel vanilla-geometry-kernel) &key surfaces proper-faces) (declare (ignore surfaces proper-faces)) (error "Don't know how to make stitched solid with ~s.~%" geometry-kernel)) (defmethod make-transformed-brep ((geometry-kernel vanilla-geometry-kernel) brep &key translation x-vector y-vector scale-vector shrink? sew-and-orient?) (declare (ignore brep translation x-vector y-vector scale-vector shrink? sew-and-orient?)) (error "Don't know how to make transformed-brep with ~s.~%" geometry-kernel)) (defmethod make-ruled-surface ((geometry-kernel vanilla-geometry-kernel) &key curve-1 curve-2 (direction :u)) (declare (ignore curve-1 curve-2 direction))) (defmethod iwbrep-sew-faces ((geometry-kernel vanilla-geometry-kernel) brep &key (tolerance 0.01)) (declare (ignore brep tolerance)) (error "Don't know how to sew faces using ~s.~%" geometry-kernel)) (defmethod tag-edges ((geometry-kernel vanilla-geometry-kernel) brep brep-id) (declare (ignore brep brep-id)) (error "Don't know how to tag edges using ~s.~%" geometry-kernel)) (define-vanilla-wrapper brep-assert-valid (native-brep &key warn?)) (define-vanilla-wrapper approximate-surface (points normals &key u-start v-start u-required v-required tolerance)) (define-vanilla-wrapper loft-surface* (curves &key rail-1 rail-2 v-degree tolerance)) (define-vanilla-wrapper interpolate-c11-surface (points &key tangent-method)) (define-vanilla-wrapper return-compatible-surfaces (surfaces &key length)) (define-vanilla-wrapper return-compatible-curves (curves &key length)) (define-vanilla-wrapper join-surfaces (surface1 surface2 &key tolerance direction)) (define-vanilla-wrapper brep-intersect (brep other-brep &key tolerance angle-tolerance)) (define-vanilla-wrapper brep-intersect? (brep other-brep &key tolerance angle-tolerance)) (define-vanilla-wrapper is-surface-rational (surface)) (define-vanilla-wrapper max-second-deriv (curve)) (define-vanilla-wrapper curve-extent (curve)) (define-vanilla-wrapper reduce-curve-degree (native-curve tolerance)) (define-vanilla-wrapper gprcap (curve &key tolerance)) (define-vanilla-wrapper poly-brep-get-brep-mesh (native-poly-brep)) (define-vanilla-wrapper brep-calculate-tight-bounding-box (brep)) (define-vanilla-wrapper get-filled-regions (brep)) (define-vanilla-wrapper make-brep-from-regions (brep-in regions)) (define-vanilla-wrapper brep-validate-and-update-tolerances (native-brep)) (define-vanilla-wrapper brep-planar-section-curves (native-brep plane-point plane-normal &key tolerance angle-tolerance-radians)) (define-vanilla-wrapper make-offset-surface (&key surface offset-distance u-degree v-degree parameterization tolerance)) (define-vanilla-wrapper make-offset-brep (brep &key distance tolerance)) (define-vanilla-wrapper make-shelled-brep (brep &key distance tolerance)) (define-vanilla-wrapper read-brep-from-file (file-name &key finalize-on)) (define-vanilla-wrapper make-brep-manifold (brep &key finalize-on regions-to-keep keep-internal-faces?)) (define-vanilla-wrapper brep-get-tolerance (brep)) (define-vanilla-wrapper brep-reset-tolerance (brep)) (define-vanilla-wrapper copy-face-to-new-brep (brep face)) (define-vanilla-wrapper make-extended-surface (&key surface curve direction which-end continuity)) (define-vanilla-wrapper make-approximated-curve (&key curve tolerance pinned-parameters)) (define-vanilla-wrapper split-surface-at-param (&key native-surface u-or-v parameter)) (define-vanilla-wrapper skin-with-spine (&key profile-curves synchronized? spine-curve spine-parameters align-profiles? spine-z-axis subdivision-level derivative-selection skinning-degree u-or-v)) (define-vanilla-wrapper interpolate-conic (&key points parameterization tangency smooth-corners?)) (define-vanilla-wrapper make-coons-patch (&key curve-left curve-right curve-bottom curve-top derivative-left derivative-right derivative-bottom derivative-top)) (define-vanilla-wrapper make-approximated-subsurface (&key surface curve-top curve-bottom curve-left curve-right curve-top-uv curve-bottom-uv curve-left-uv curve-right-uv)) (define-vanilla-wrapper curve-subdivide-at-discontinuities (&key curve continuity-type continuity-angle)) (define-vanilla-wrapper merge-brep (&key brep brep-to-merge copy-brep-map)) (define-vanilla-wrapper merge-breps (&key breps operation)) (define-vanilla-wrapper sew-brep (&key brep tolerances)) (define-vanilla-wrapper surface-create-silhouette-curves (&key surface eye-point-or-vector perspective? tolerance angle-tolerance)) (define-vanilla-wrapper tooccl (curve &key tolerance)) (define-vanilla-wrapper curve-knot-scale (curve &key u-min u-max)) (define-vanilla-wrapper surf-grid-points (surface &key u-parameters v-parameters u-direction v-direction)) (define-vanilla-wrapper closed-boolean-operation (&key first-brep rest-breps operation approximation-tolerance angle-tolerance sew-and-orient? manifold?)) (define-vanilla-wrapper closed-boolean-separate-operation (&key first-brep other-brep approximation-tolerance angle-tolerance sew-and-orient? manifold?)) (define-vanilla-wrapper global-brep-brep-solve (brep &key other-brep operation-type distance-tolerance)) (define-vanilla-wrapper get-faces-from-edge (edge)) (define-vanilla-wrapper reduce-surface-knot (surface &key tolerance direction)) (define-vanilla-wrapper make-extend-curve (curve &key distance distance-type extending-from continuity)) (define-vanilla-wrapper approximated-compatible-curves (curve-list &key length tolerance)) (define-vanilla-wrapper make-tx-assembly-instance (&key name)) (define-vanilla-wrapper tx-assembly-add-subassembly (parent-assembly-instance-pointer child-assembly-instance-pointer)) (define-vanilla-wrapper tx-assembly-add-brep (assembly-instance-pointer native-brep &key name red green blue)) (define-vanilla-wrapper tx-assembly-add-curve (assembly-instance-pointer native-curve &key name red green blue)) (define-vanilla-wrapper tx-assembly-add-point (assembly-instance-pointer point &key name red green blue)) (define-vanilla-wrapper rational-to-nonrational (curve &key tolerance maintain-end-tangents? nonrational-degree parameterization)) (define-vanilla-wrapper make-spiral (height radius-1 radius-2 pitch right-or-left tolerance)) (define-vanilla-wrapper make-cardinal-spline (&key control-points tension-params periodic? parameterization)) (define-vanilla-wrapper make-degenerate-curve (&key degree point))
40,585
Common Lisp
.lisp
561
62.771836
165
0.696864
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
7c0a7d954bae64d05bce8402b5216f57f96d8db7b28973ded45bd45f78c81a54
35,864
[ -1 ]
35,865
blended-solid.lisp
lisp-mirror_gendl/surf/source/blended-solid.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object blended-solid (brep) :documentation (:description "This primitive attempts to fillet one or more edges of a brep solid." :examples "<pre> (in-package :gdl-user) (define-object blend-sample (base-object) :objects ((box :type 'box-solid :length 10 :width 20 :height 15) (blend :type 'blended-solid :display-controls (list :color :blue) :default-radius 3 :brep (the box)))) (generate-sample-drawing :objects (the-object (make-object 'blend-sample) blend) :projection-direction (getf *standard-views* :trimetric)) </pre>") :input-slots ("GDL Brep object. This is the original solid, whose edges you want to be filleted." brep "Number. This will be used as the fillet radius." default-radius ("Plist with key :edges. This specifies which edges are to be filleted. The default (nil) means that all edges should be filleted." specs nil)) :computed-slots ((%native-brep% (let ((brep (make-blended-brep *geometry-kernel* (the brep) :default-radius (the default-radius) :specs (the specs)))) (tag-edges *geometry-kernel* brep (get-long *geometry-kernel* brep)) brep)))) (define-object test-blended-mixin (blended-solid) :computed-slots ((default-radius 1) (display-controls (list :color :green :transparency 0.5)) (visible-children (list-elements (the edges))) )) #+nil (define-object test-blended-subtracted (test-blended-mixin) :computed-slots ((specs (list :edges (remove-if #'(lambda(edge) (the-object edge unique-id)) (list-elements (the brep edges)))))) :objects ((brep :type 'test-subtracted-solid))) (define-object test-blended-united (test-blended-mixin) :objects ((brep :type 'test-united-solid))) (define-object test-blended-intersected (test-blended-mixin) :objects ((brep :type 'test-intersected-solid)))
3,065
Common Lisp
.lisp
68
36.911765
115
0.65989
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
13eaa1866b27c422cc4be407d9047a395c4d815020c6db87bb9007dd5899df43
35,865
[ -1 ]
35,866
fitted-surface.lisp
lisp-mirror_gendl/surf/source/fitted-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object fitted-surface (surface) :documentation (:description "Fits a surface through a net of points with given degrees and parameterizations. Currently only interpolated surfaces are supported, this will be extended to allow smooth fitting without the surface necessarily interpolating (going through) each of the points." :examples "<pre> (in-package :gdl-user) (define-object c11-test (surface) :input-slots () :computed-slots () :objects ((surf-test :type 'fitted-surface :hidden nil :c11? t :points (list (list (make-point -1 0 0) (make-point 0 0 0) (make-point 0.001 0.0 0) (make-point 1 1 0) (make-point 1.001 1 0) (make-point 2 1 0) (make-point 2.001 1 0) (make-point 3 2 0) (make-point 3.001 2.001 0) (make-point 4 3 0) (make-point 5 4 0)) (list (make-point -1 0 1) (make-point 0 0 1) (make-point 0.001 0.0 1) (make-point 1 1 1) (make-point 1.001 1 1) (make-point 2 1 1) (make-point 2.001 1 1) (make-point 3 2 1) (make-point 3.001 2.001 1) (make-point 4 3 1) (make-point 5 4 1)))))) (#+allegro excl:without-package-locks #-allegro progn (define-object test-fitted-surface (fitted-surface) :input-slots ((display-controls (list :color :green-spring :isos (list :n-v 19 :n-u 19))) (grid-width 4 :settable) (grid-length 4 :settable) (grid-height 4 :settable)) :computed-slots ((points (list (list (make-point 0 0 0) (make-point (/ (the grid-width) 4) 0 0) (make-point (half (the grid-width)) 0 0) (make-point (* 3/4 (the grid-width)) 0 0) (make-point (the grid-width) 0 0)) (list (make-point 0 (/ (the grid-length) 4) 0) (make-point (/ (the grid-width) 4) (/ (the grid-length) 4) (/ (the grid-height) 4)) (make-point (half (the grid-width)) (/ (the grid-length) 4) (* (/ (the grid-height) 4) 1.6)) (make-point (* 3/4 (the grid-width)) (/ (the grid-length) 4) (/ (the grid-height) 4)) (make-point (the grid-width) (/ (the grid-length) 4) 0)) (list (make-point 0 (half (the grid-length)) 0) (make-point (/ (the grid-width) 4) (half (the grid-length)) (* (/ (the grid-height) 4) 1.8)) (make-point (half (the grid-width)) (half (the grid-length)) (the grid-height)) (make-point (* 3/4 (the grid-width)) (half (the grid-length)) (* 3/4 (the grid-height))) (make-point (the grid-width) (half (the grid-length)) 0)) (list (make-point 0 (* 3/4 (the grid-length)) 0) (make-point (/ (the grid-width) 4) (* 3/4 (the grid-length)) (min (* (/ (the grid-height) 4) (* (/ (the grid-height) 4) 1.4)) (the grid-height))) (make-point (half (the grid-width)) (* 3/4 (the grid-length)) (min (* (/ (the grid-height) 4) (* (/ (the grid-height) 4) 1.8)) (the grid-height))) (make-point (* 3/4 (the grid-width)) (* 3/4 (the grid-length)) (/ (the grid-height) 4)) (make-point (the grid-width) (* 3/4 (the grid-length)) 0)) (list (make-point 0 (the grid-length) 0) (make-point (/ (the grid-width) 4) (the grid-length) 0) (make-point (half (the grid-width)) (the grid-length) 0) (make-point (* 3/4 (the grid-width)) (the grid-length) 0) (make-point (the grid-width) (the grid-length) 0))))))) (generate-sample-drawing :objects (make-object 'test-fitted-surface) :projection-direction :trimetric) </pre>") :input-slots ("List of lists of 3D Points. The points for fitting, with inner lists representing U direction and outer lists V direction." points ("List of 3D vectors of same length as points, or nil. If given, these are the surface normals at each point." normals nil) ("Integer. The starting degree for the fit algorithm in the U direction. Default is 1." u-start 1) ("Integer. The starting degree for the fit algorithm in the V direction. Default is 1." v-start 1) ("Integer. The desired degree of the resultant surface in the U direction. Default is 3." u-degree 3) ("Integer. The desired degree of the resultant surface in the V direction. Default is 3." v-degree 3) ("Keyword symbol, one of :uniform, :chord-length, :centripetal. The parameterization to use in the resultant surface if interpolant? is t. Default is :chord-length" parameterization :chord-length) ("Boolean. Indicates whether the surface will interpolate the points. Defaults to t." interpolant? t) ("Boolean. If interpolated, indicates whether to compute a C11 continuous nonrational bicubic NURBS surface. Defaults to nil." c11? nil) ("Keyword symbol, one of :bessel, :akima. The method used to compute tangents. Defaults to :akima." tangent-method :akima) ("Number. Tolerance for fit. Defaults to *3d-approximation-tolerance-default*." tolerance *3d-approximation-tolerance-default*)) :computed-slots ((native-surface (cond ((the interpolant?) (cond ((the c11?) (interpolate-c11-surface *geometry-kernel* (the points) :tangent-method (the tangent-method))) (t (interpolate-surface *geometry-kernel* (the points) (the u-degree) (the v-degree) (the parameterization))))) ((the normals) (approximate-surface *geometry-kernel* (the points) (the normals))) (t (approximate-surface *geometry-kernel* (the points) (the normals) :u-start (the u-start) :u-required (the u-degree) :v-start (the v-start) :v-required (the v-degree) :tolerance (the tolerance))))) (bounding-box (bounding-box-from-points (flatten (the points))))))
9,248
Common Lisp
.lisp
154
37.584416
130
0.476612
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
c4f792476ee411632f9f9d883ac0709a3d719e00bfc4d58ddc9bc1df325c18be
35,866
[ -1 ]
35,867
geometry-kernel-object-mixin.lisp
lisp-mirror_gendl/surf/source/geometry-kernel-object-mixin.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object geometry-kernel-object-mixin () :documentation (:description "This mixin provides messages common to all NURBS-based objects whose underlying implementation comes from a modular geometry kernel such as SMLib.") :input-slots ((from-iges? nil)) :input-slots ( ("List of integers. The IGES-compatible levels (layers) on which this object resides. GDL does not currently support writing out multiple levels (layers) through the IGES writer ; only the first of these will be output if the object is exported with the IGES output-format (please contact Genworks if you need all levels (layers) to be written out)." levels (get-levels *geometry-kernel* self)) ("Integer. The primary IGES-compatible level (layer) on which this object resides. Defaults to the first of the levels. This slot can be overridden in user code to specify a new layer which will be written out when this object is exported with the IGES output-format." layer (first (the levels))) ("Integer. Synonym for the layer." iges-level (the layer)) (color-hex (lookup-color (the color-decimal) :format :hex)) ("Vector of three real numbers. The RGB color of this object as imported from an external format (e.g. IGES) or as specified in :display-controls. Defaults to the foreground color specified in <tt>*colors-default*</tt>. This message should not normally be overridden in user application code." color-decimal (let ((color (when (the from-iges?) (get-color *geometry-kernel* self)))) (or color (multiple-value-bind (result found?) (lookup-color (getf (the display-controls) :color)) (when found? result)))))) :computed-slots ((%line-vertex-indices% (let ((count -1)) (mapcar #'(lambda(line) (declare (ignore line)) (list (incf count) (incf count))) (the %lines-to-draw%)))) (%vertex-array% (append (flatten-lines (the %lines-to-draw%)) (flatten-curves (the %curves-to-draw%)))) (%unique-id% (or (get-long *geometry-kernel* self) (let ((id (read-from-string (subseq (string (gensym)) 1)))) (format t "Setting object %unique-id% on-demand for object ~s.~%" self) (set-long *geometry-kernel* self id) id)))))
3,337
Common Lisp
.lisp
55
52.509091
151
0.679591
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
a210b9e980fe43aed8daeebdf6d7da6f4f1d7ca846700b382b658d731e695a4e
35,867
[ -1 ]
35,868
step-reader.lisp
lisp-mirror_gendl/surf/source/step-reader.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object step-reader (base-object) :documentation (:description "This object will reflect the contents of a STEP file containing points, curves, surfaces, and/or trimmed surfaces as sequences of GDL objects. Currently all surfaces are treated as trimmed, where actual untrimmed surfaces have their natural outer boundaries as the result-island, i.e. no standalone surfaces will be produced by this part. This is a default option in the HarmonyWare STEP Translator which will be exposed in GDL in a future release. The HarmonyWare reader creates a log file in a temporary directory. The location of this log file is printed on the console during the reading operation. Currently this log file is not automatically deleted, and its name is determined by the system. ") :input-slots ("String or pathname. The location of the STEP file to be read." file-name ("Boolean. If true, treat all untrimmed surfaces in the file as if they are trimmed surfaces with the natural outer boundary of the surface as the trimming loop. If used, no standalone IwSurface surface objects will ever be returned by the reader. Default is nil." make-all-surfaces-trimmed? nil) #+nil ("Boolean. If true, treat all B-reps in the file as if they are collections of trimmed surfaces. This loses all B-rep connectivity contained in the file. Its use is not recommended. Default is nil." break-up-breps-into-trimmed-surfaces? nil) ("Boolean. If true, group all trimmed surfaces in the file into one B-rep. If some trimmed surfaces are blanked, they are grouped into a second, blanked B-rep. Default is nil." group-trimmed-surfaces-into-brep? nil) ("Boolean. If true, group all trimmed surfaces and B-reps in the file into one B-rep. If some trimmed surfaces or B-reps are blanked, they are grouped into a second, blanked B-rep. Default is nil." make-single-brep? nil) ("Boolean. Indicates whether each resulting brep should have its faces sewn together. Default is (the make-single-brep?)." sew-brep-faces? (the make-single-brep?)) ) :computed-slots ((data (read-step-file* *geometry-kernel* (let ((file (namestring (translate-logical-pathname (the file-name))))) (if (probe-file file) file (error "~a: file not found.~%" file))) :finalize-on self :make-all-surfaces-trimmed? (the make-all-surfaces-trimmed?) ;;:break-up-breps-into-trimmed-surfaces? (the break-up-breps-into-trimmed-surfaces?) :group-trimmed-surfaces-into-brep? (the group-trimmed-surfaces-into-brep?) :make-single-brep? (the make-single-brep?)))) :objects (("Sequence of GDL point objects. The points found in the STEP file." points :type 'point :sequence (:size (length (getf (the data) :points))) :center (nth (the-child index) (getf (the data) :points))) ("Sequence of GDL curve objects. The curves found in the STEP file." curves :type 'curve :from-iges? t :sequence (:size (length (getf (the data) :curves))) :native-curve-iw (nth (the-child index) (getf (the data) :curves))) ("Sequence of GDL surface objects. The untrimmed ``standalone'' surfaces found in the STEP file." surfaces :type 'surface :sequence (:size (length (getf (the data) :surfaces))) :native-surface (nth (the-child index) (getf (the data) :surfaces))) ("Sequence of GDL brep objects. The breps and trimmed surfaces (represented as breps) found in the STEP file." breps :type 'brep :from-iges? t :sequence (:size (length (getf (the data) :trimmed-surface-breps))) :%native-brep% (let ((brep (nth (the-child index) (getf (the data) :trimmed-surface-breps)))) (when (the sew-brep-faces?) (iwbrep-sew-and-orient brep)) (if brep brep (error "Brep is nil for some reason")))))) ;; ;; Input tests ;; (define-object step-test-reader (step-reader) :computed-slots ((file-name "/tmp/as1-oc-214.stp"))) (define-object step-test-tree-reader (step-reader) :computed-slots ((file-name "/tmp/step-test-tree.stp")))
5,480
Common Lisp
.lisp
88
52.159091
140
0.677482
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
69938b89997bb60590be4f10fe004021a771d2706f89cffd39bf999e31ca9512
35,868
[ -1 ]
35,869
iges-reader.lisp
lisp-mirror_gendl/surf/source/iges-reader.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object iges-reader (base-object) :documentation (:description "This object will reflect the contents of an iges file containing points, curves, surfaces, and/or breps (including trimmed surfaces) as sequences of GDL objects. The HarmonyWare reader creates a log file in a temporary directory. The location of this log file is printed on the console during the reading operation. Currently this log file is not automatically deleted, and its name is determined by the system. ") :input-slots ("String or pathname. The location of the IGES file to be read." file-name ("Boolean. If true, treat all untrimmed surfaces in the file as if they are trimmed surfaces with the natural outer boundary of the surface as the trimming loop. If used, no standalone IwSurface surface objects will ever be returned by the reader. Default is nil." make-all-surfaces-trimmed? nil) #+nil ("Boolean. If true, treat all B-reps in the file as if they are collections of trimmed surfaces. This loses all B-rep connectivity contained in the file. Its use is not recommended. Default is nil." break-up-breps-into-trimmed-surfaces? nil) ("Boolean. If true, group all trimmed surfaces in the file into one B-rep. If some trimmed surfaces are blanked, they are grouped into a second, blanked B-rep. Default is nil." group-trimmed-surfaces-into-brep? nil) ("Boolean. If true, group all trimmed surfaces and B-reps in the file into one B-rep. If some trimmed surfaces or B-reps are blanked, they are grouped into a second, blanked B-rep. Default is nil." make-single-brep? nil) ("Boolean. Indicates whether each resulting brep should have its faces sewn together. Default is (the make-single-brep?)." sew-brep-faces? (the make-single-brep?))) :computed-slots ((data (read-iges-file* *geometry-kernel* (format nil "~a" (translate-logical-pathname (the file-name)) ) :finalize-on self :make-all-surfaces-trimmed? (the make-all-surfaces-trimmed?) ;;:break-up-breps-into-trimmed-surfaces? (the break-up-breps-into-trimmed-surfaces?) :group-trimmed-surfaces-into-brep? (the group-trimmed-surfaces-into-brep?) :make-single-brep? (the make-single-brep?)))) :objects (("Sequence of GDL point objects. The points found in the IGES file." points :type 'point :sequence (:size (length (getf (the data) :points))) :center (nth (the-child index) (getf (the data) :points))) ("Sequence of GDL curve objects. The curves found in the IGES file." curves :type 'curve :from-iges? t :sequence (:size (length (getf (the data) :curves))) :native-curve-iw (nth (the-child index) (getf (the data) :curves))) ("Sequence of GDL surface objects. The untrimmed ``standalone'' surfaces found in the IGES file." surfaces :type 'surface :sequence (:size (length (getf (the data) :surfaces))) :native-surface (nth (the-child index) (getf (the data) :surfaces))) ("Sequence of GDL brep objects. The breps and trimmed surfaces (represented as breps) found in the IGES file." breps :type 'brep :from-iges? t :sequence (:size (length (getf (the data) :trimmed-surface-breps))) :%native-brep% (let ((brep (nth (the-child index) (getf (the data) :trimmed-surface-breps)))) (when (the sew-brep-faces?) (iwbrep-sew-and-orient brep)) (if brep brep (error "Brep is nil for some reason")))))) ;; Input tests ;; (define-object iges-test-tree-reader (iges-reader) :computed-slots ((file-name "/tmp/iges-test-tree.iges"))) (define-object iges-quarter (iges-reader) :computed-slots ((file-name "/tmp/quarter.iges"))) (define-object iges-quarter-hw (iges-reader) :computed-slots ((file-name "/tmp/quarter-model-hw.iges")))
5,194
Common Lisp
.lisp
83
52.168675
140
0.675261
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
f9a43c9fff901d176f7bbf491af214cb8dab9963c23c3537c887ba8da9ddd1fc
35,869
[ -1 ]
35,870
general-dual-blend-surface.lisp
lisp-mirror_gendl/surf/source/general-dual-blend-surface.lisp
;; ;; Copyright 2002-2011 Genworks International ;; ;; This source file is part of the General-purpose Declarative ;; Language project (GDL). ;; ;; This source file contains free software: you can redistribute it ;; and/or modify it under the terms of the GNU Affero General Public ;; License as published by the Free Software Foundation, either ;; version 3 of the License, or (at your option) any later version. ;; ;; This source file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Affero General Public License for more details. ;; ;; You should have received a copy of the GNU Affero General Public ;; License along with this source file. If not, see ;; <http://www.gnu.org/licenses/>. ;; (in-package :surf) (define-object general-dual-blend-surface (b-spline-surface) :documentation (:description "Creates a smooth blend-surface between curve-1, lying on surface-1 and curve-2 on surface-2. The local start and end directions of this surface along curve-1 and curve-2 are specified by the user with parametric functions." :examples "<pre> (in-package :surf) (define-object test-g-d-b-s (base-object) :computed-slots ((f-tangent-1 #'(lambda(param) (rotate-vector-d (the (face-normal-vector :top)) -10 (the curve-1 (tangent param))))) (f-tangent-2 #'(lambda(param) (rotate-vector-d (the (face-normal-vector :bottom)) 10 (the curve-2 (tangent param))))) (f-ratio-1 #'(lambda(param) (declare (ignore param)) 1/3)) (f-ratio-2 #'(lambda(param) (declare (ignore param)) 1/3))) :objects ((g-d-b-s :type 'general-dual-blend-surface :display-controls (list :color :green) :pass-down (f-tangent-1 f-tangent-2 f-ratio-1 f-ratio-2 curve-1 surface-1 curve-2 surface-2)) (surf-1-top :type 'linear-curve :hidden? t :start (make-point -5 -5 0) :end (make-point 5 -5 0)) (surf-1-bottom :type 'linear-curve :hidden? t :start (make-point -7 -10 -2) :end (make-point 7 -10 -2)) (surface-1 :type 'ruled-surface :curve-1 (the surf-1-top) :curve-2 (the surf-1-bottom)) (curve-1 :type 'iso-curve :display-controls (list :color :red :line-thickness 4) :surface (the surface-1) :parameter 0 :u-or-v :v) (surf-2-bottom :type 'linear-curve :hidden? t :start (make-point -5 5 0) :end (make-point 5 5 0)) (surf-2-top :type 'linear-curve :hidden? t :start (make-point -7 10 2) :end (make-point 7 10 2)) (surface-2 :type 'ruled-surface :curve-1 (the surf-2-bottom) :curve-2 (the surf-2-top)) (curve-2 :type 'iso-curve :display-controls (list :color :blue :line-thickness 4) :surface (the surface-2) :parameter 0 :u-or-v :v))) (generate-sample-drawing :object-roots (list (make-object 'test-g-d-b-s)) :projection-direction (getf *standard-views* :trimetric)) </pre>" ) :input-slots ("Input-function. Parametric function defined from 0 to 1 that outputs the blend-surface's local direction vector along curve-1. The input value of 0 corresponds to the start of curve-1, 1 to the end of curve-1." f-tangent-1 "Input-function. Parametric function defined from 0 to 1 that outputs the blend-surface's local direction vector along curve-2. The input value of 0 corresponds to the start of curve-2, 1 to the end of curve-2." f-tangent-2 ("Input-function. Parametric function defined from 0 to 1 that outputs the blend-surface's local blend-ratio along curve-1. The input value of 0 corresponds to the start of curve-1, 1 to the end of curve-1. The output local blend-ratio can be any number greater than 0, but the resulting blend surface can become erratic for values greater than 1. Defaults to a constant value of 1/3." f-ratio-1 #'(lambda(param) (declare (ignore param)) 1/3)) ("Input-function. Parametric function defined from 0 to 1 that outputs the blend-surface's local blend-ratio along curve-2. The input value of 0 corresponds to the start of curve-2, 1 to the end of curve-2. The output local blend-ratio can be any number greater than 0, but the resulting blend surface can become erratic for values greater than 1. Defaults to a constant value of 1/3." f-ratio-2 #'(lambda(param) (declare (ignore param)) 1/3)) "GDL curve. Curve lying on surface-1 that forms the starting-edge of the blend-surface" curve-1 "GDL surface. Surface that is to be connected to surface-2 by the blend-surface" surface-1 "GDL curve. Curve lying on surface-2 that forms the ending-edge of the blend-surface" curve-2 "GDL surface. Surface that is to be connected to surface-1 by the blend-surface" surface-2 ("Number. Number of b-spline-segments of the resulting blend-surface in the parametric direction along curve-1 and curve-2. Defaults to 50." n-segments 50)) :computed-slots ((control-point-distances (mapcar #'3d-distance (the (fits 0) control-points) (the (fits 1) control-points))) (control-points (list (the (fits 0) control-points) (the (fits 0) new-control-points) (the (fits 1) new-control-points) (the (fits 1) control-points))) ;; ;; FLAG -- ensure compatible knot vector between (the fits). ;; (u-knot-vector (the (fits 0) knot-vector)) ;;(v-knot-vector) (u-degree (the (fits 0) degree)) (v-degree 3) ) :hidden-objects ((fits :type 'blending-fitted-curve :sequence (:size 2) ;; ;; FLAG -- duplicate call to equi-spaced-paramters (happens again in equi-spaced-points) ;; :equi-parameters (ecase (the-child index) (0 (the curve-1 (equi-spaced-parameters (the n-segments)))) (1 (the curve-2 (equi-spaced-parameters (the n-segments))))) :points (ecase (the-child index) (0 (the curve-1 (equi-spaced-points (the n-segments)))) (1 (the curve-2 (equi-spaced-points (the n-segments))))) :vector-function (ecase (the-child index) (0 (the f-tangent-1)) (1 (the f-tangent-2))) :ratio-function (ecase (the-child index) (0 (the f-ratio-1)) (1 (the f-ratio-2))) :pass-down (control-point-distances)))) (define-object blending-fitted-curve (fitted-curve) :input-slots (equi-parameters vector-function ratio-function control-point-distances) :computed-slots ((take-off-vectors (mapcar (the vector-function) (the equi-parameters))) (distances (mapcar #'(lambda(distance parameter) (* distance (funcall (the ratio-function) parameter))) (the control-point-distances) (the equi-parameters))) (new-on-curve-points (the (translate-points (the points)))) (new-control-points (the (translate-points (the control-points)))) ) :objects ((control-grid :type 'points-display :points (the control-points))) :functions ( (translate-points (points) (mapcar #'(lambda(point vector distance) (translate-along-vector point vector distance)) points (the take-off-vectors) (the distances)))))
8,479
Common Lisp
.lisp
153
41.993464
448
0.608838
lisp-mirror/gendl
0
0
0
AGPL-3.0
9/19/2024, 11:44:17 AM (Europe/Amsterdam)
38dad4f82113fd2e7d5e2e20aa79e7a032ee033fe5a04a9d7e0310cdd20c5160
35,870
[ -1 ]