public abstract class Abstract3dModel extends Object implements IModel
Immutable implementation of IModel interface and adds convenient methods to make it easier to move or rotate the 3D models. Every primitive 3D object and 3D transition extend this class.
None of the methods changing this object rather creates a new object with the changes and gives that changed object back. This make cloning and other similar techniques unnecessary.
Constructor and Description |
---|
Abstract3dModel() |
Modifier and Type | Method and Description |
---|---|
Abstract3dModel |
addModel(Abstract3dModel model)
Convenient method to create a Union.
|
Abstract3dModel |
addModelTo(Side side,
Abstract3dModel model)
Convenient method to create a Union.
|
Abstract3dModel |
align(Side place,
Abstract3dModel model)
Moves this model to the position relative to the given model.
|
Abstract3dModel |
align(Side place,
Abstract3dModel model,
boolean inside)
Deprecated.
Use
align(Side, Abstract3dModel) instead. |
Abstract3dModel |
align(Side place,
Coords3d coords)
Moves this model to the position relative to the given coordinate.
|
Abstract3dModel |
align(String innerAnnotation,
Side place,
Abstract3dModel model)
Moves this model to the position relative to the annotated part of the given model.
|
Abstract3dModel |
align(String innerAnnotation,
Side place,
Abstract3dModel model,
String externalAnnotation)
Moves this model to the position relative to the annotated part of the given model.
|
Abstract3dModel |
annotate(String annotation)
Annotate this object with the given annotation.
|
Abstract3dModel |
background()
Creates a new object with the background flag set, which means it will render in a transparent
light gray color in preview mode and is skipped in CGAL rendering or STL export.
|
protected Abstract3dModel |
cloneModel()
Creates a clone of this model, so after the cloning any change on it won't affect.
|
Abstract3dModel |
debug()
Creates a new object with the debug flag set, which means it is rendered in a different color
in preview mode (it does not affect the CGAL rendering or STL export).
|
protected List<Abstract3dModel> |
findAnnotatedModel(String annotation) |
Boundaries3d |
getBoundaries()
Calculate the including cuboid for the current model.
|
protected abstract List<Abstract3dModel> |
getChildrenModels() |
protected abstract Boundaries3d |
getModelBoundaries() |
protected int |
getTag()
For testing purposes only.
|
protected abstract Abstract3dModel |
innerCloneModel() |
protected abstract Abstract3dModel |
innerSubModel(IScadGenerationContext context) |
protected abstract SCAD |
innerToScad(IColorGenerationContext context)
Generates the OpenSCAD representation of the model without.
|
protected boolean |
isBackground()
For testing purposes only.
|
protected boolean |
isDebug()
For testing purposes only.
|
boolean |
isMoved()
Returns true if this object is moved false otherwise.
|
protected abstract boolean |
isPrimitive()
Returns true if and only if this object represents a primitive, atomic 3D object.
|
boolean |
isRotated()
Returns true if the result will contain rotating transformation.
|
Abstract3dModel |
move(Coords3d delta)
Moves this object by the given coordinates.
|
Abstract3dModel |
moves(Collection<Coords3d> delta)
Add moves to this model, which converts this to an
Union , representing more than one model. |
Abstract3dModel |
moves(Coords3d... delta)
Add moves to this model, which converts this to an
Union , representing more than one model. |
Abstract3dModel |
moves(List<Coords3d> delta,
List<String> annotations)
Add moves to this model, which converts this to an
Union , representing more than one model. |
Abstract3dModel |
moves(List<Coords3d> delta,
String... annotations)
Add moves to this model, which converts this to an
Union , representing more than one model. |
Abstract3dModel |
rotate(Angles3d delta)
Creates a new object by rotating this object with the given angle.
|
Abstract3dModel |
rotates(Angles3d... delta)
Add rotates to this model, which converts this to an
Union , representing more than one model. |
Abstract3dModel |
rotates(Collection<Angles3d> delta)
Add rotates to this model, which converts this to an
Union , representing more than one model. |
Abstract3dModel |
round(Plane plane,
double radius)
Rounding this object with the given radius.
|
Abstract3dModel |
subModel(IScadGenerationContext context)
Copies parts of the model to a new model based on the given context.
|
Abstract3dModel |
subtractModel(Abstract3dModel model)
Convenient method to create a Difference.
|
CSG |
toCSG()
Renders this model to its CSG interpretation - convenient method which used the default
generation context.
|
CSG |
toCSG(FacetGenerationContext aContext)
Renders this model to its CSG interpretation.
|
protected abstract CSG |
toInnerCSG(FacetGenerationContext context) |
SCAD |
toScad(IColorGenerationContext context)
Renders this model and returns with the generated OpenSCAD code.
|
Abstract3dModel |
withTag(int tag)
Tag the model with the given value.
|
public Abstract3dModel move(Coords3d delta)
delta
- the coordinates used by the movepublic Abstract3dModel moves(Collection<Coords3d> delta)
Add moves to this model, which converts this to an Union
, representing more than one model.
delta
- the collection of coordinates used by the move operationpublic Abstract3dModel moves(List<Coords3d> delta, String... annotations)
Add moves to this model, which converts this to an Union
, representing more than one model.
The moved objects is annotated with the given list of annotations respectively. There has to be an equal number of moves and annotations given, otherwise an exception is thrown.
If any item in the annotations list is null that copy of the object won't be annotated.
It is very convenient with the use of Coords3d.createVariances. For example:
object.moves(new Coords3d(1,1,0).createVariances(), "+1+1", "+1-1", "-1+1", "-1-1")
delta
- the collection of coordinates used by the move operationannotations
- the list of annotations to be usedIllegalValueException
- in case the number of moves and annotations are not equalpublic Abstract3dModel moves(List<Coords3d> delta, List<String> annotations)
Add moves to this model, which converts this to an Union
, representing more than one model.
The moved objects is annotated with the given list of annotations respectively. There has to be an equal number of moves and annotations given, otherwise an exception is thrown.
If any item in the annotations list is null that copy of the object won't be annotated.
delta
- the collection of coordinates used by the move operationannotations
- the list of annotations to be usedIllegalValueException
- in case the number of moves and annotations are not equalpublic Abstract3dModel moves(Coords3d... delta)
Union
, representing more than one model.delta
- the collection of coordinates used by the move operationpublic Abstract3dModel rotate(Angles3d delta)
delta
- the angle it will be rotatedpublic Abstract3dModel rotates(Collection<Angles3d> delta)
Union
, representing more than one model.
This object won't be changed.delta
- the collection of angles used by the rotate operationpublic Abstract3dModel rotates(Angles3d... delta)
Union
, representing more than one model.
This object won't be changed.delta
- the collection of angles used by the rotate operationpublic Abstract3dModel debug()
public Abstract3dModel background()
protected abstract List<Abstract3dModel> getChildrenModels()
protected final List<Abstract3dModel> findAnnotatedModel(String annotation)
public Abstract3dModel annotate(String annotation)
Annotate this object with the given annotation.
An object can be annotated by several annotation at the same time. A new annotation never overrides an old one.
If the given parameter is null this method does nothing.
annotation
- the annotation will be used - can be nullprotected final Abstract3dModel cloneModel()
protected abstract Abstract3dModel innerCloneModel()
protected abstract SCAD innerToScad(IColorGenerationContext context)
protected abstract boolean isPrimitive()
public final SCAD toScad(IColorGenerationContext context)
IModel
protected abstract Boundaries3d getModelBoundaries()
public final Boundaries3d getBoundaries()
public boolean isRotated()
public boolean isMoved()
@Deprecated public Abstract3dModel align(Side place, Abstract3dModel model, boolean inside)
align(Side, Abstract3dModel)
instead.Moves this model to the position relative to the given model. The position is controlled by
the place - see Side
- and inside parameters.
place
- where to move this modelmodel
- the model used as a reference pointinside
- controls which side of the aligned model will be alignedpublic Abstract3dModel align(Side place, Abstract3dModel model)
Moves this model to the position relative to the given model. The position is controlled by
the place - see Side
- parameter.
place
- where to move this modelmodel
- the model used as a reference pointpublic Abstract3dModel align(String innerAnnotation, Side place, Abstract3dModel model)
Moves this model to the position relative to the annotated part of the given model.
The position is controlled by the place - see Side
- parameter.
innerAnnotation
- the annotated part of this object which will be used for the positioning.
Can be null which case it does filter anything and the call is equivalent to
align(place, model)
place
- where to move this modelmodel
- the model used as a reference pointIllegalValueException
- if there are more than one pieces of this model is annotated with innerAnnotationpublic Abstract3dModel align(String innerAnnotation, Side place, Abstract3dModel model, String externalAnnotation)
Moves this model to the position relative to the annotated part of the given model.
The position is controlled by the place - see Side
- parameter.
In case more than one pieces of the target object is annotated with externalAnnotation this model will be aligned to all of them and the returned object will be the union of those new objects.
innerAnnotation
- the annotated part of this object which will be used for the positioning.
Can be null which case it does not filter on the source side.place
- where to move this modelmodel
- the model used as a reference pointexternalAnnotation
- the annotation used to filter the target object.
Can be null which case it does not filter on the target side.IllegalValueException
- if there are more than one pieces of this model is annotated with innerAnnotation
or if there are no pieces of the target model is annotated with externalAnnotationpublic Abstract3dModel align(Side place, Coords3d coords)
Moves this model to the position relative to the given coordinate. The position is controlled by
the place - see Side
.
place
- where to move this modelcoords
- the coordinates used as a reference pointpublic Abstract3dModel round(Plane plane, double radius) throws IllegalValueException
Rounding this object with the given radius. It is possible to round only on one plane, or rounding all around the object.
Please pay attention that the rounding increases the objects size with the given radius.>
plane
- the rounding will happen on this plane - or all around if it set to ALL.radius
- the radius of the roundingIllegalValueException
- if the given radius is negativeprotected abstract CSG toInnerCSG(FacetGenerationContext context)
public final CSG toCSG(FacetGenerationContext aContext)
IModel
public final CSG toCSG()
public Abstract3dModel withTag(int tag)
tag
- the value to be usedpublic Abstract3dModel addModel(Abstract3dModel model)
model
- the model to be added to this objectpublic Abstract3dModel addModelTo(Side side, Abstract3dModel model)
model1.addModelTo(side, model2)
is always equivalent to
model1.addModel(model2.align(side, model1, false))
.side
- where to move this modelmodel
- the model to be added to this objectaddModel(Abstract3dModel)
public Abstract3dModel subtractModel(Abstract3dModel model)
model
- the model to be subtracted to this objectprotected abstract Abstract3dModel innerSubModel(IScadGenerationContext context)
public Abstract3dModel subModel(IScadGenerationContext context)
Copies parts of the model to a new model based on the given context. It is very useful if we want to use a tagged part of the model as a separate model. Lots of things can be done to the new model: we can render it or we can use it to align to it.
If the given context is the ScadGenerationContextFactory.DEFAULT
then this method call is logically
equivalent to a cloneModel()
method call.
context
- the context to be used as a filter during the copy process.protected int getTag()
protected boolean isDebug()
protected boolean isBackground()
Copyright © 2014–2020, Printing in 3D. All rights reserved.