<?xml version="1.0"?>

<st-source>
<!-- 
Name: CADSM-Basic
HideSource: false
PackageName: CADSM
Parcel: #('cadsmbasic')
SaveSource: true
Version: 2
Date: 1:00:15 pm October 30, 2009
 -->
<time-stamp>From VisualWorks®, 7.5 of April 16, 2007 on October 30, 2009 at 1:00:15 pm</time-stamp>


<do-it>(Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned.  Choose terminate or close.']</do-it>

<class>
<name>CADSMItem</name>
<environment>Smalltalk</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>CADSM-Basic</category>
<attributes>
<package>CADSM</package>
</attributes>
</class>

<class>
<name>CADSMSubItem</name>
<environment>Smalltalk</environment>
<super>CADSMItem</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>cEventHandler aSup </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>CADSM-Basic</category>
<attributes>
<package>CADSM</package>
</attributes>
</class>

<class>
<name>CADSMSupItem</name>
<environment>Smalltalk</environment>
<super>CADSMSubItem</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>cSub </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>CADSM-Basic</category>
<attributes>
<package>CADSM</package>
</attributes>
</class>

<class>
<name>CADSMCoordinateFrame</name>
<environment>Smalltalk</environment>
<super>CADSMSupItem</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>body </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>CADSM-Basic</category>
<attributes>
<package>CADSM</package>
</attributes>
</class>

<class>
<name>CADSMAbstractSphericalFrame</name>
<environment>Smalltalk</environment>
<super>CADSMCoordinateFrame</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>CADSM-Basic</category>
<attributes>
<package>CADSM</package>
</attributes>
</class>

<class>
<name>CADSMAbstractCartesianFrame</name>
<environment>Smalltalk</environment>
<super>CADSMCoordinateFrame</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>CADSM-Basic</category>
<attributes>
<package>CADSM</package>
</attributes>
</class>

<class>
<name>CADSMAbstractCylindricalFrame</name>
<environment>Smalltalk</environment>
<super>CADSMCoordinateFrame</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>CADSM-Basic</category>
<attributes>
<package>CADSM</package>
</attributes>
</class>

<methods>
<class-id>CADSMItem</class-id> <category>initialize-release</category>

<body package="CADSM" selector="initialize">initialize
	^self</body>
</methods>

<methods>
<class-id>CADSMItem</class-id> <category>comparing</category>

<body package="CADSM" selector="=">= aObject 
	self subclassResponsibility</body>
</methods>

<methods>
<class-id>CADSMItem</class-id> <category>accessing</category>

<body package="CADSM" selector="aSortedCollectionByName">aSortedCollectionByName
	^SortedCollection sortBlock: [:a :b | a name &lt;= b name]</body>
</methods>

<methods>
<class-id>CADSMItem class</class-id> <category>instance creation</category>

<body package="CADSM" selector="new">new
	^super new initialize</body>
</methods>

<methods>
<class-id>CADSMItem class</class-id> <category>utilities</category>

<body package="CADSM" selector="imagePath">imagePath
	^ObjectMemory imageDirectory asString</body>
</methods>

<methods>
<class-id>CADSMSubItem</class-id> <category>private event table</category>

<body package="CADSM" selector="myEventTable">myEventTable
	^cEventHandler</body>

<body package="CADSM" selector="myEventTable:">myEventTable: anEventTable 
	cEventHandler := anEventTable</body>
</methods>

<methods>
<class-id>CADSMSubItem</class-id> <category>change</category>

<body package="CADSM" selector="changed">changed
	self triggerEvent: #changed</body>
</methods>

<methods>
<class-id>CADSMSubItem</class-id> <category>accessing</category>

<body package="CADSM" selector="aMbDClass">aMbDClass
	^self class aMbDClass</body>

<body package="CADSM" selector="aMbDUnits">aMbDUnits
	^aSup ifNotNil: [aSup aMbDUnits]</body>

<body package="CADSM" selector="aMediator">aMediator
	^aSup ifNotNil: [aSup aMediator]</body>

<body package="CADSM" selector="asTreeNode">asTreeNode
	| answer |
	answer := CADSM.UI.CADSMUITreeNode new.
	answer geoItem: self.
	answer displayString: self name.
	^answer</body>

<body package="CADSM" selector="aSup">aSup
	^aSup</body>

<body package="CADSM" selector="aSup:">aSup: anObject
	aSup := anObject</body>

<body package="CADSM" selector="cDiscontinuity:">cDiscontinuity: cDiscontinuity 
	self removeActionsForEvent: #cDiscontinuity.
	cDiscontinuity notNil 
		ifTrue: 
			[self 
				when: #cDiscontinuity
				ask: cDiscontinuity
				perform: #yourself]</body>

<body package="CADSM" selector="dataSeries">dataSeries
	| answer |
	answer := self triggerEvent: #getDataSeries.
	answer isNil 
		ifTrue: 
			[answer := OrderedCollection new.
			self dataSeries: answer].
	^answer</body>

<body package="CADSM" selector="dataSeries:">dataSeries: dataSeries 
	self removeActionsForEvent: #getDataSeries.
	dataSeries notNil ifTrue: [self
			when: #getDataSeries
			ask: dataSeries
			perform: #yourself]</body>

<body package="CADSM" selector="deleteMbD">deleteMbD
	self mbdObject: nil</body>

<body package="CADSM" selector="discontinuities:">discontinuities: discontinuities 
	self cDiscontinuity: discontinuities</body>

<body package="CADSM" selector="fullName">fullName
	| stream |
	stream := WriteStream on: (String new: 256).
	self fullpath do: [:node | (node respondsTo: #name)
			ifTrue: [node name isString
					ifTrue: 
						[stream nextPut: $/.
						stream nextPutAll: node name]]].
	^stream contents asSymbol</body>

<body package="CADSM" selector="fullpath">fullpath
	| fullpath |
	fullpath := aSup isNil 
				ifTrue: [OrderedCollection new]
				ifFalse: [aSup fullpath].
	fullpath add: self.
	^fullpath</body>

<body package="CADSM" selector="geoTime">geoTime
	^aSup ifNotNil: [aSup geoTime]</body>

<body package="CADSM" selector="interface">interface
	^self aMediator</body>

<body package="CADSM" selector="mbdObject:">mbdObject: mbdObject 
	self removeActionsForEvent: #mbdObject.
	mbdObject ifNotNil: 
			[self 
				when: #mbdObject
				ask: mbdObject
				perform: #yourself]</body>

<body package="CADSM" selector="name">name
	^self triggerEvent: #name</body>

<body package="CADSM" selector="name:">name: name 
	self removeActionsForEvent: #name.
	name ifNotNil: 
			[self 
				when: #name
				ask: name asSymbol
				perform: #yourself]</body>

<body package="CADSM" selector="notes:">notes: notes 
	self removeActionsForEvent: #getNotes.
	notes notNil 
		ifTrue: 
			[self 
				when: #getNotes
				ask: notes
				perform: #yourself]</body>

<body package="CADSM" selector="removeSup">removeSup
	aSup ifNotNil: [:aaSup | aaSup removeSub: self]</body>
</methods>

<methods>
<class-id>CADSMSubItem</class-id> <category>testing</category>

<body package="CADSM" selector="isAssembly">isAssembly
	^false</body>

<body package="CADSM" selector="isJoint">isJoint
	^false</body>

<body package="CADSM" selector="isMotion">isMotion
	^false</body>

<body package="CADSM" selector="isUniverse">isUniverse
	^false</body>
</methods>

<methods>
<class-id>CADSMSubItem</class-id> <category>copying</category>

<body package="CADSM" selector="postCopy">postCopy
	super postCopy.
	cEventHandler := nil.
	aSup := nil</body>
</methods>

<methods>
<class-id>CADSMSupItem</class-id> <category>accessing</category>

<body package="CADSM" selector="addSub:">addSub: aSub 
	"aSub maybe already in a tree. Make sure aSub is released by its aSup."

	aSub removeSup.
	cSub add: aSub.
	aSub aSup: self.
	^aSub</body>

<body package="CADSM" selector="aSup:">aSup: anObject 
	aSup := anObject</body>

<body package="CADSM" selector="removeSub:">removeSub: aSub 
	^(cSub remove: aSub ifAbsent: [nil]) ifNotNil: 
			[:aaSub | 
			aaSub aSup: nil.
			aaSub]</body>
</methods>

<methods>
<class-id>CADSMSupItem</class-id> <category>initialize-release</category>

<body package="CADSM" selector="initialize">initialize
	super initialize.
	cSub := CADSM.Misc.CADSMMiscOrderedSet new</body>
</methods>

<methods>
<class-id>CADSMSupItem</class-id> <category>copying</category>

<body package="CADSM" selector="postCopy">postCopy
	super postCopy.
	cSub := IdentitySet new</body>
</methods>

<methods>
<class-id>CADSMCoordinateFrame class</class-id> <category>utilities</category>

<body package="CADSM" selector="aAFfFromArrayAFf:">aAFfFromArrayAFf: arrayAFf 
	"Returns aAFf matrix from aAFf array in row order."

	| aAFf aAFfi |
	aAFf := StCAD.StMath.StMFullMatrix new: 3 by: 3.
	1 to: 3
		do: 
			[:i | 
			aAFfi := aAFf at: i.
			1 to: 3
				do: [:j | aAFfi at: j put: (arrayAFf at: j + (3 * (i - 1))) asDouble]].
	^aAFf</body>

<body package="CADSM" selector="aAFfFromArrayAFfT:">aAFfFromArrayAFfT: arrayAFfT 
	^(self aAFfFromArrayAFf: arrayAFfT) transpose</body>

<body package="CADSM" selector="arrayAFfFromAFf:">arrayAFfFromAFf: aAFf 
	"Returns array of 9 elements in row order."

	| aStream |
	aStream := (Array new: 9) writeStream.
	1 to: 3 do: [:i | aStream nextPutAll: (aAFf row: i)].
	^aStream contents</body>

<body package="CADSM" selector="arrayAFfTFromAFf:">arrayAFfTFromAFf: aAFf 
	^self arrayAFfFromAFf: aAFf transpose</body>

<body package="CADSM" selector="arrayMFfFromrFfF:aAFf:">arrayMFfFromrFfF: rFfF aAFf: aAFf 
	"Returns array of 16 elements in row order."

	| aStream |
	aStream := (Array new: 16) writeStream.
	1 to: 3
		do: 
			[:i | 
			aStream nextPutAll: (aAFf row: i).
			aStream nextPut: (rFfF at: i)].
	3 timesRepeat: [aStream nextPut: 0.0d].
	aStream nextPut: 1.0d.
	^aStream contents</body>

<body package="CADSM" selector="arrayMFfTFromrFfF:aAFf:">arrayMFfTFromrFfF: rFfF aAFf: aAFf 
	"Returns array of 16 elements in column order."

	| aStream |
	aStream := (Array new: 16) writeStream.
	1 to: 3
		do: 
			[:i | 
			aStream nextPutAll: (aAFf column: i).
			aStream nextPut: 0.0d].
	aStream nextPutAll: rFfF.
	aStream nextPut: 1.0d.
	^aStream contents</body>

<body package="CADSM" selector="rFfFaAFfFromArrayMFf:">rFfFaAFfFromArrayMFf: aMFf 
	"Returns array of rFfF and aAFf from aMFf."

	| rFfF aAFf aAFfi |
	rFfF := StCAD.StMath.StMFullColumn new: 3.
	aAFf := StCAD.StMath.StMFullMatrix new: 3 by: 3.
	1 to: 3
		do: 
			[:i | 
			rFfF at: i put: (aMFf at: 4 * i) asDouble.
			aAFfi := aAFf at: i.
			1 to: 3 do: [:j | aAFfi at: j put: (aMFf at: j + (4 * (i - 1))) asDouble]].
	^Array with: rFfF with: aAFf</body>

<body package="CADSM" selector="rFfFaAFfFromArrayMFfT:">rFfFaAFfFromArrayMFfT: aMFfT 
	"Returns array of rFfF and aAFf from aMFfT."

	| rFfF aAFf aAFfi |
	rFfF := StCAD.StMath.StMFullColumn new: 3.
	aAFf := StCAD.StMath.StMFullMatrix new: 3 by: 3.
	1 to: 3
		do: 
			[:i | 
			rFfF at: i put: (aMFfT at: i + 12) asDouble.
			aAFfi := aAFf at: i.
			1 to: 3 do: [:j | aAFfi at: j put: (aMFfT at: i + (4 * (j - 1))) asDouble]].
	^Array with: rFfF with: aAFf</body>

<body package="CADSM" selector="r_theta_z_xyz:">r_theta_z_xyz: xyz 
	| x y z |
	x := xyz at: 1.
	y := xyz at: 2.
	z := xyz at: 3.
	^StCAD.StMath.StMArray 
		with: (x * x + (y * y)) sqrt
		with: (Double arcTan0to2piY: y overX: x)
		with: z</body>

<body package="CADSM" selector="xyz_r:theta:z:">xyz_r: r theta: theta z: z 
	^StCAD.StMath.StMFullColumn 
		with: r * theta cos
		with: r * theta sin
		with: z</body>
</methods>

<methods>
<class-id>CADSMAbstractCartesianFrame</class-id> <category>copying</category>

<body package="CADSM" selector="postCopy">postCopy
	super postCopy.
	body := nil</body>
</methods>

<methods>
<class-id>CADSMAbstractCartesianFrame</class-id> <category>accessing</category>

<body package="CADSM" selector="body">body
	^body</body>

<body package="CADSM" selector="body:">body: aObject 
	body := aObject</body>
</methods>

<do-it>"Imported Classes:"</do-it>

<do-it>self error: 'Attempting to file-in parcel imports.  Choose terminate or close'</do-it>

<class>
<name>Object</name>
<environment>Core</environment>
<super></super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Kernel-Objects</category>
<attributes>
<package>Kernel-Objects</package>
</attributes>
</class>

</st-source>
